Dash API
Using the API
from GN.DashAPI import DashAPI
# Get a list of all tools in the scene.
scene_tools = DashAPI.getActiveTools()
# Iterate over each tool, and print the name of its container type properties.
for tool in scene_tools:
props = tool.getPropertiesByType(DashAPI.PropertyTypes.SceneContainer)
for prop in props:
print(f"{prop.getName()} - {prop.getValue()}")
# Get the active tool that's visible in the Tools Panel.
active_tool = DashAPI.getActiveTool()
# Find its property "Surface", and set its value to the current scene selection.
surface_prop = active_tool.getProperty("surface")
selection = DashAPI.Scene.fromSelection()
if surface_prop and selection:
surface_prop.setValue(selection)
# Rename the property
surface_prop.setName("Selection")
# Select the objects that the active tool generates
tool_output = DashAPI.getToolOutput(active_tool)
# Hide its result
tool_output.setVisibility(False)
# Delete the active tool
DashAPI.deleteTool(active_tool)
# Create a new tool by its name
tool = DashAPI.createTool("surface scatter", show=True)
# Adjust its properties
tool.setValue("surface", DashAPI.Scene.fromObjectNames(["ground_plane"]))
tool.setValue("scatter", DashAPI.Scene.fromSelection())
tool.setValue("density", 0.75)
tool.setValue("min scale", 0.70)
tool.setValue("seed", DashAPI.randomSeed())
# Save the settings as a preset. This won't save the container properties.
new_preset = DashAPI.saveToolPreset(tool)
# Create a new tool
new_tool = DashAPI.createTool("Surface Scatter")
# Assign the preset to it
DashAPI.setToolPreset(new_tool, new_preset)
Creating a Tool
Instancing Tool
Mesh Generation Tool
Last updated
Was this helpful?