Open model and start simulation 4DScript

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
chaix
Posts: 8
Joined: Friday 26 April, 2019 - 15:06

Open model and start simulation 4DScript

Post by chaix » Monday 29 April, 2019 - 17:22

Hello everyone,

I would like open an existing model using 4DScript and start the simulation, what are the corresponding lines of code?

Thanks in advance

User avatar
HarryBunnik
Posts: 304
Joined: Monday 07 February, 2011 - 11:22

Re: Open model and start simulation 4DScript

Post by HarryBunnik » Monday 29 April, 2019 - 17:37

Ha chaix,

There are a few things that you'll have to cover before loading a model on code. I cut the code in 3 blocks.

Note that t = a global variable that must contain as a string the name and location of the model to be loaded.

Note that not all code will be directly necessary, like the "progressbar" commands can most likely be skipped..

{Remove old already loaded model (if available) and prepare for the new model}
do(
{ destroy model contents }
if(
AtomExists(model),
do(
DestroyAtom(model, True),
ExperimentReset,

{Set auto analyze}
If(
AtomByName([Experiment Support], library) > 0,
Att([auto_analyze], AtomByName([Experiment Support], library)) := 1
)
)
),
{ recreate model }
if(
not(atomexists(model)),createmodel),
setattributes(1, model),
setattributename(1, [model Name]),
settextatt(1, [Untitled]),
updatemodelname(att(1, model)),
sddb([t-nocreate], 1, model),
AtomTreeRefresh(1)
)


{Load new model: t must contain the model with directory which must be loaded.}
Do(
waitcursor,
DisplayLayers(0),
DestroyLight,
progressbarforopen(1, t),
execfile(t),
updatemodelname(t),
progressbarforopen(0),
normalcursor
)

{Run model}
Do(
Run
)

I hope this helps you further. Regarding your other question concerning Java, I'm still looking into it.

Regards,

Harry

chaix
Posts: 8
Joined: Friday 26 April, 2019 - 15:06

Re: Open model and start simulation 4DScript

Post by chaix » Tuesday 30 April, 2019 - 10:42

Thank you very much Harry

Post Reply