Dash API
使用 API
from GN.DashAPI import DashAPI
# 获取场景中所有工具的列表。
scene_tools = DashAPI.getActiveTools()
# 遍历每个工具,并打印其容器类型属性的名称。
for tool in scene_tools:
props = tool.getPropertiesByType(DashAPI.PropertyTypes.SceneContainer)
for prop in props:
print(f"{prop.getName()} - {prop.getValue()}")
# 获取在工具面板中可见的活动工具。
active_tool = DashAPI.getActiveTool()
# 找到它的属性 "Surface",并将其值设置为当前场景选择。
surface_prop = active_tool.getProperty("surface")
selection = DashAPI.Scene.fromSelection()
if surface_prop and selection:
surface_prop.setValue(selection)
# 重命名该属性
surface_prop.setName("Selection")
# 选择该活动工具生成的对象
tool_output = DashAPI.getToolOutput(active_tool)
# 隐藏其结果
tool_output.setVisibility(False)
# 删除活动工具
DashAPI.deleteTool(active_tool)
# 通过名称创建一个新工具
tool = DashAPI.createTool("surface scatter", show=True)
# 调整其属性
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())
# 将设置保存为预设。这不会保存容器属性。
new_preset = DashAPI.saveToolPreset(tool)
# 创建一个新工具
new_tool = DashAPI.createTool("Surface Scatter")
# 将预设分配给它
DashAPI.setToolPreset(new_tool, new_preset)
创建工具
实例化工具
网格生成工具
最后更新于
这有帮助吗?