This section is mostly for TDs and Tech Animators.
This is not exactly and API, but there are ways to run BroDynamics simulations from your own scripts, if and when you need to automate the process.
Running simulation from Python¶
Here's an example:
simulator = BroTools.BroDynamics.modules.chain.SimulatorModule() simulator.run(objects, **simulationParameters)
simulationParameters should be a dict that contains:
- preserveAnimation - boolean - preserfe animation or not
- simulationProperties - a dict of simulation properties. These are directly fed into either nParticle of nHair object, so you can use any. For a list of existing properties refer to json files in BroTools\BroDynamics\config folder (chain_properties.json and point_properties.json)
- shiftDistance - float - distance to shift additional locator for
- collisionMode - boolean - collision mode on or off
- dontRefresh - boolean - refresh or not
- colliders - list of objects to turn into colliders
- skipControls - int - number of controls to skip
- skipFrames - int - number of frames to skip
- aimRotation - boolean - match rotations or not
- matchPositions - boolean - match translations or not
- debugMode - boolean - use debug mode or not
- deleteNucleus - boolean - delete nucleus after simulation or leave it
- up - list showing which axis is up ([x,y,z])
- axis - list showing which axis is front ([x,y,z])
Running Batch simulation from Python¶
Here's how you can run Batch simulation from Python.
import BroTools BroTools.BroDynamics.BroDynamicsUI.initUI() BroTools.BroDynamics.BroDynamicsUI.BroDynamicsWindow.BroBatchWindow.show() BroTools.BroDynamics.BroDynamicsUI.BroDynamicsWindow.BroBatchWindow.refreshDropdowns() BroTools.BroDynamics.BroDynamicsUI.BroDynamicsWindow.BroBatchWindow.startBatchSimulation()
This will load the first broDynamics_Data node in your scene and run a batch simulation for all objects which are setup in that node.
You can also change the node, by manually switching the id of the dropdown control, here's how you can access it: