Page 1 of 1
Open model and start simulation 4DScript
Posted: Monday 29 April, 2019 - 17:22
by chaix
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
Re: Open model and start simulation 4DScript
Posted: Monday 29 April, 2019 - 17:37
by HarryBunnik
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
Re: Open model and start simulation 4DScript
Posted: Tuesday 30 April, 2019 - 10:42
by chaix
Thank you very much Harry