Versions Compared

Key

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

...

The script loops through a spline node's ("Spline01") control points and adds bounded "Noise Field" daemons at the points' positions. Furthermore, the script checks if there is a "Noise_Daemons" groups in the scene. If not, a new group will be created:

Code Block
languagepy
# Get the spline "Spline01" and its number of control points
# Get the scene's groups
spline         = scene.getSpline("Spline01")
numCP          = spline.getNumberOfControlPoints()
radius         = 2.0
existingGroups = scene.getGroups()
 

# If the scene does not contain any groups create a new one and name it "Noise_Daemons"
if (len(existingGroups) == 0):
	group = scene.addGroup()
	group.setName("Noise_Daemons")
 

# If there are groups check if one of them is name "Noise_Daemons"...
else:
	for entry in existingGroups:
		if (entry.getName() == "Noise_Daemons"):
			group = entry
 
# ...otherwise create a new group
		else:
			group = scene.addGroup()
			group.setName("Noise_Daemons")
 

# Go through the spline's control points
for controlPoint in range(0, numCP):
	cpPosition = spline.getControlPointPosition(controlPoint)
 

	# Add a new daemon per control point
	daemon = scene.addDaemon("Noise Field")
 

	# Configure the daemon and make it bounded
	# Place at the control point's position
	# Add the daemon to the "Noise_Daemons" group
	daemon.setParameter("Enable falloff", True)
	daemon.setParameter("Display falloff", True)
	daemon.setParameter("Falloff percent", 0.0)
	daemon.setParameter("Falloff bounds", "Sphere")
	daemon.setParameter("Scale", Vector.new(radius, radius, radius))
	daemon.setParameter("Position", cpPosition)
	group.add(daemon.getName())