question

Donghuang L3 avatar image
0 Likes"
Donghuang L3 asked Jason Lightfoot edited

Lost object attributes when creating instances from custom library.

Hi, I have created my User Library for Custom Objects, and use FlexScript codes to generate object instances.
I included some scripts under the behaviour attributes (the OnPreDraw codes) -- I realize that such scripts may need to be build explicitly using Build Node FlexScript.
I found that, when using the createinstance() method, the behaviour attributes of the Customer Object is lost (while all other attributes are OK). However, when I directly drag a copy from the library to the model, such attributes were kept.
Would you please help me figure out how to keep those attributes while using codes only to create object instances? Thanks.

Object Behaviour configured in User Library:
1691952882481.png



Object Behaviour lost when created using createinstance() method:
1691952882481.png


1691952899062.png1691952899062.png


FlexSim 23.2.0
user librarycreateinstance
1691952882481.png (17.5 KiB)
1691952899062.png (15.0 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

createinstance() is for creating instances of classes from the main library. You should be using ceatecopy().

· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.