Querying the AutoCAD Document
Read from the drawing — get hold of objects that already exist, inspect them, and select them with filters.
Bringing an AutoCAD object into Grasshopper
The most direct way to get existing AutoCAD geometry into a definition is to reference it with a parameter:
- From the Params ▸ AutoCAD group, drop the parameter for the type you want onto the canvas — for a hatch, the AutoCAD Hatch param.
- Right-click the param and choose Set One AutoCAD Hatch (or Set Multiple AutoCAD Hatches to pick several).
- Grasshopper hands control to AutoCAD — click the hatch in the drawing to select it.
- The param now holds a live reference to that object, which you can wire into the rest of your definition.
This is the interactive, one-object-at-a-time counterpart to the filter-based querying further down — ideal when you just want to grab a specific object you can see.
Dropping an AutoCAD Hatch param, choosing "Set One AutoCAD Hatch", and picking the hatch in the drawing.
Everything defaults to the active document
You'll notice that many AutoCAD components have a Document (Doc) input, and that it's optional. If you leave it empty, the component automatically uses the currently active AutoCAD document. You only need to wire a Document in when you want to target a specific, non-active drawing.
In other words, you can usually ignore the Document input entirely while you're working in a single drawing — it just falls back to the active one.
If you do need to work with documents explicitly, the AutoCAD Document component (AC-Doc, AutoCAD ▸ Document) decomposes a document into properties such as its file name, file path, read-only state, and whether it's the active document.
The DBObject component
Every object in an AutoCAD drawing — a line, a block reference, a layer, a hatch — is ultimately a DBObject. The AutoCAD DBObject component (AC-DbObj, AutoCAD ▸ Document) takes advantage of this: feed it almost any AutoCAD object (or its Id) and it extracts the common properties they all share, including:
- the object's Type,
- its Layer (name and Id),
- its Color, Material (name and Id), and Linetype (name and Id),
- its Extension Dictionary Id (the attached-data dictionary mentioned in AutoCAD-Native Types).
Because it works at the DBObject level, it's a handy general-purpose inspector for whatever you've pulled out of the drawing, without needing a type-specific component for every case.
Filters — selecting what you want
To pull objects out of the drawing you use the Get AutoCAD Objects By Filter component (AC-GetByFilter, AutoCAD ▸ Filter). It takes an optional Document (active by default), a Filter describing what to select, and an optional Limit (default 100; use 0 for unlimited), and returns the matching Objects and a Count.
The filter itself is where you say what to fetch.
The default (geometry-type) filter. The simplest filter selects by object type. Drop the AutoCAD Geometry Filter Type value list (AutoCAD ▸ Filter), pick a type — Curve, Point, Mesh, Solid, Hatch, Text, Block, Layer, and so on — and wire it into the Filter input. (You can even type the name as plain text; it's converted to the matching filter for you.) This single-type filter covers most everyday queries, like "give me every curve in the drawing."
Composite filters. When one type isn't enough, combine filters:
- And Filter (
AC-AndFilter) — matches objects that satisfy both Filter A and Filter B. - Or Filter (
AC-OrFilter) — matches objects that satisfy either Filter A or Filter B.
Because each combiner outputs a single filter, you can chain them — feed the output of one And/Or into another — to build up as specific a selection rule as you need. There's also a Layer Filter (AC-LayerFilter) to match everything on a given layer, and, for advanced cases, a Create Custom Filter (AC-CustomFilter) that builds a filter from raw DXF filter rules.
A simple geometry-type filter (left) and a composite And/Or filter, both feeding the Get AutoCAD Objects By Filter component.
As with AutoCAD-native types, this is an orientation — enough to start querying the drawing. Explore the Filter group to see every filter type available.
Stale data and Refresh
The Get AutoCAD … components — Get AutoCAD Layers, Get AutoCAD Block References and the rest of the family you met in AutoCAD-Native Types — read a snapshot of the drawing. When the drawing changes underneath them they do not recompute on their own. They mark their data stale and wait for you.
A stale component: the capsule turns pale blue, the message reads "Stale Data", and a Refresh button appears below it.
- The component tells you what changed, in a remark reading "Data is stale: 2 added, 1 deleted, 4 modified. Press Refresh to update." The counts build up across successive AutoCAD commands until you refresh.
- Press Refresh to clear the stale state and re-solve against the current drawing. Any other re-solve clears it too — an upstream change on the canvas, or a manual recompute.
- Right-click ▸ Auto Update switches the component back to recomputing by itself on every relevant change, exactly as it behaved before v1.3.0. It is off by default.
Why it works this way. Recomputing on every document change can in some cases create feedback loops — a Grasshopper component writes to the AutoCAD drawing, the change expires a Grasshopper Get component, its recompute writes again, and the definition never settles. Marking data stale breaks the loop, and makes it visible what the drawing did while you were working.
Get AutoCAD Objects By Filter is the exception. It has its own Query button and its own Auto Update toggle — also off by default — and never shows the stale state. With Auto Update off it holds no result until you press Query.