> For the complete documentation index, see [llms.txt](https://docs.polygonflow.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.polygonflow.io/advanced/dash-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.polygonflow.io/~gitbook/mcp).

# Dash API

Dash's codebase is a mix of native Python code, C++ libraries, UE Python API code, etc...\
To make it easier to navigate, we've built a simple interface class through which you can access most useful functionalities. Before we dig in, a few things to keep in mind:

* Dash is an editor-only plugin, and doesn't operate at runtime.

## Using the API

DashAPI is an interface class that groups all the most common and useful features you'll want to interact with. There's a wide range of classes, functions and libraries that Dash uses, and you can go through them as we often add simple docstrings a bit everywhere.\
However, the goal of DashAPI is to avoid that need for most basics.

```python
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

```python
from GN.GNL.ToolCreation import ToolDescriptor, ToolRunner

class GraphNTool(ToolRunner):

    def __init__(self):
        super(GraphNTool, self).__init__()

    def run(self, *args, **kwargs):
        return

    @staticmethod
    def createDescriptor():
        tool = ToolDescriptor(identifier=128930, name='Compound Tool',
                              description='This is a simple test tool')
        tool.setCompoundTool(True)

        return tool
```

### Mesh Generation Tool

```python
from GN.GNL.ToolCreation import ToolDescriptor, ToolRunner

class GraphNTool(ToolRunner):

    def __init__(self):
        super(GraphNTool, self).__init__()

    def run(self, *args, **kwargs):
        return

    @staticmethod
    def createDescriptor():
        tool = ToolDescriptor(identifier=128930, name='Compound Tool',
                              description='This is a simple test tool')
        tool.setCompoundTool(True)

        return tool
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.polygonflow.io/advanced/dash-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
