...
The script automatically fills a selected object (select exactly one closed object, e.g. a cube, sphere, or torus) with Dyverso particles. For this process a fill object and a collision object is needed:
- A Dyverso domain and a "Fill" emitter are added and linked in the "Relationship Editor".
- The object's "Volume" is set to "Solid inside" to make it fillable.
- The object is attached to the Dyverso emitter and then unlinked from the "Relationship Editor", because it is only used to create the particles.
- The object is copied and its "Volume mode" is set to "Solid outside" – now the copied objects acts as a collision object.
- The scene is reset to add the particles.
Code Block | ||
---|---|---|
| ||
fillObjects# Get the selected nodes fillObjects = scene.getSelectedNodes() dyversoDomain = scene.add_DY_Domain() dyversoEmitter = scene.add_DY_Emitter("Fill") # Check if there is just one node selected, otherwise print out a warning if (len(fillObjects) =!= 01): scene.message("Select exactlyone oneclosed object!") # If there is one node selected check if it is really an object else: for node in fillObjects: if (node.getType() == TYPE_OBJECT): # Add a domain and a fill emitter dyversoDomain = scene.add_DY_Domain() dyversoEmitter = scene.add_DY_Emitter("Fill") # Change the object's volume mode dyversoEmitter.setParameter("Object", node.getName()) node.setParameter("Volume mode", "Solid inside") # Remove the object's link from the "Relationship Editor" # Create an exclusive link between domain and emitter scene.removeGlobalLink(node) scene.addExclusiveLink(dyversoDomain, dyversoEmitter) # Create a copy of the object and change its volume mode nodeCopy = node.clone() nodeCopy.setParameter("Volume mode", "Solid outside") # If you did not select an object print out a warning else: scene.message("Select an object.") # Reset the scene to fill the object scene.reset() |