Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The script prints out the names of all scene nodes:

Code Block
languagepy
# Get all nodes in the scene
sceneNodes = scene.getNodes()
 
# Loop through every node and print out its name
for node in sceneNodes:
	nodeName = node.getName()
	scene.message(nodeName)

...

The script renames objects inside the "Object_Group" and adds leading 0s:

Code Block
languagepy
# Get the group "Object_Group" and its contained nodes
objectGroup = scene.getGroup("Object_Group")
objects     = objectGroup.getNodes()
namePrefix  = "RealFlow_Object_"
counter     = 0
 

# Loop through every object and assemble a padding format
for entry in objects:
	if (counter < 10)                   : padding = "00"+str(counter)
	if (counter >= 10 and counter < 100): padding = "0"+str(counter)
	if (counter >= 100)                 : padding = str(counter)
 


	# Assemble the complete name, consisting of prefix and padding
	completeName = namePrefix+padding
 
	# Set the new name
	entry.setName(completeName)
 
	# Increment the counter
	counter += 1

Grouping Nodes

Add this script to a "Batch Script" editor (F10) and execute it with Script > Run.

The script looks for daemons in the scene and groups them under a new "Daemon_Group" node:

Code Block
languagepy
# Get the scene's daemons and add a new group
daemons = scene.getDaemons()
group   = scene.addGroup()
 

# Rename the new group to "Daemon_Group"
group.setName("Daemon_Group")
 

# Loop through the daemons and add each node to the new group
for entry in daemons:
	group.add(entry.getName())

...

The script changes a node selection's visibility to hidden:

Code Block
languagepy
# Get the scene's selected nodes
nodeSelection = scene.getSelectedNodes()

# Loop through the nodes and unify their visibility (here: invisible)
for entry in nodeSelection:
	entry.setParameter("Visible", False) # make the nodes visible again with ("Visible", True)

...

The script sets the nodes from the "Rigid_Bodies" group to inactive:

Code Block
languagepy
# Get the scene's "Rigid_Bodies" group and its contained nodes
group = scene.getGroup("Rigid_Bodies")
groupNodes = group.getNodes()
 

# Loop through the nodes and make them inactive
for entry in groupNodes:
	entry.setParameter("Simulation", "Inactive")