The following are scripting limitations and caveats:
Undo/Redo: Playing a script constitutes a single undoable and re-doable action.
SuspendRegenerating/RestoreRegenerating: You will see these functions called in recordings. SuspendRegenerating suspends the updating of geometry. RestoreRegenerating restores the updating of geometry and causes the geometry to regenerate if needed. These functions are used to speed up performance of scripts which create and modify geometry. If you call SuspendRegenerating in your script, create a box and then query the box's body count, it will return zero because the bodies haven't been created yet. The solution is to call RestoreRegenerating before you query the modified geometry. Please note that these calls can be nested - every call to SuspendRegenerating should be matched by a call to RestoreRegenerating.
Simulation jobs: When a simulation is executed by calling Simulate, Mesh, etc., that function returns a Python job object (IJob). If your script then relies on results of the simulation, your script needs to wait until the job completes. Some functions like ISimulation::RefineSolution and ISimulation::Reset internally wait on all jobs, but post processing functions such as accessing results through annotations or measurements do not. In those cases you need to call Wait() on the job first.
PyJob_1 = PySimulation_1.Simulate() PyJob_1.Wait() # access annotation that uses results from PySimulation_1
analyst.New(): The script function analyst.New() deletes the current model and creates then returns a new model. When the original model is deleted all existing script objects associated with that model are deleted.
mymodel = analyst.GetModel() mynewmodel = analyst.New() mymodel = analyst.GetModel() # need to get the model again after a New() # use mymodel ...