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
Open model and start simulation 4DScript
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Open model and start simulation 4DScript
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
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
Thank you very much Harry