Query AutoCAD Plant 3D Project Data
AutoCAD Plant 3D publishes data from Plant 3D Collaboration projects to the AEC Data Model using the standard AEC Data Model navigation flow through hubs, projects, and folders. This tutorial therefore does not repeat those standard queries. Plant 3D differs at the elementGroup level: a published Plant 3D Collaboration project produces two elementGroups in two separate Forma folders, one for P&ID (2D) data and one for piping (3D) data.
The following diagram shows the workflow for retrieving Plant 3D project data. Everything up to and including the folder queries follows the standard AEC Data Model flow. The split into the two elementGroups is where the behavior specific to Plant 3D begins.
In this tutorial, you learn how to:
- Locate the two elementGroups that a Plant 3D project publishes.
- Filter elements by object type using the
tableNamesproperty. - Scope a query to a single drawing.
- Query custom properties, which use a different parameter ID format.
- Query relationship data using the
pnpClassNameproperty.
Before You Begin
Complete the following:
- Publish an AutoCAD Plant 3D Collaboration project to the AEC Data Model.
- Sign in to the AEC Data Model Explorer with your Autodesk account.
- Complete Get Hubs and Get Projects to obtain the hub ID and project ID for your Plant 3D project.
- Read Navigate to ElementGroups within a Project for the general elementGroup query pattern.
Note
Sync status is not currently exposed for AutoCAD Plant 3D database publishing. Publishing a
Plant 3D project commits its files immediately, but synchronization progress and completion
status are not visible. An initial publish can take up to approximately 2 hours to fully sync,
and typically completes within 30 to 60 minutes. Subsequent Plant 3D check-ins are processed
incrementally and usually complete within seconds to minutes, depending on the volume of changes.
elementGroupExtractionStatus does not cover Plant 3D data sets. Treat an empty or partial
result soon after a publish as synchronization still in progress rather than as a query error.
This tutorial uses these abbreviations:
- P&ID — Piping and Instrumentation Diagram, the 2D design data in a Plant 3D project.
- DWG — an AutoCAD drawing file.
Step 1: Locate the Two ElementGroups of a Plant 3D Project
A Plant 3D project publishes two elementGroups, not one. When you publish a Plant 3D Collaboration project, Forma creates two data set files, and each maps to one elementGroup:
| Forma folder | Data set file | Contents |
|---|---|---|
PID DWG |
P&ID Data Set | P&ID (2D) design data |
Plant 3D Models |
3D Piping Data Set | Piping (3D) design data |
Because 2D and 3D data live in separate elementGroups, every element query targets one or the other. Choose the elementGroup that holds the objects you want before you filter. Querying the wrong one returns no results even when the filter itself is correct. For example, P&ID objects such as hand valves and instruments are in the 2D elementGroup, and piping objects such as pipes, fittings, and equipment are in the 3D elementGroup.
Note
Data set files published from AutoCAD Plant 3D do not increment version in Forma Design Management. They remain at version V1 even as the underlying Plant 3D data is updated, because the platform allows a maximum of 10,000 versions per file. Data updates are still synchronized correctly and reflected in the latest content. Do not use the data set file version to tell whether a publish has been synchronized, and do not expect version-based queries to return a publish history for Plant 3D data.
Before you run the query, obtain the ID of the Forma folder in the preceding table for the data you
want. Read the ID from the folder web URL, where it appears as the folderUrn value. If the
Plant 3D project is shared into a sub-folder of the Forma project, call foldersByFolder
repeatedly until you reach the folder. Then retrieve the elementGroup ID for that folder.
Note
Query the PID DWG and Plant 3D Models folders directly rather than a folder higher up the
project tree. A Plant 3D project stores thousands of DWG, spec, XML, and other files alongside its
two data sets, so a search across sub-folders can return the data sets many pages into the result
set. For details on pagination behavior, see
Navigate to ElementGroups within a Project.
- In the Query Pane of the AEC Data Model Explorer, enter the following query:
Query
query GetPlant3dElementGroupsByFolder($projectId: ID!, $folderId: ID!, $filter: ElementGroupFilterInput, $pagination: PaginationInput) { elementGroupsByFolder( projectId: $projectId folderId: $folderId filter: $filter pagination: $pagination ) { pagination { pageSize cursor } results { name id } } }Show More - In the Query Variables Pane, enter the following values, using the folder ID you obtained:
Query Variables
{ "projectId": "{{YOUR_PROJECT_ID}}", "folderId": "{{YOUR_FOLDER_ID}}", "filter": { "searchType": "ALL" } }searchTypeis required whenever you pass afilter. Set it toALLto return every elementGroup in the folder. - Click Play. The response is similar to the following:
Response
{ "data": { "elementGroupsByFolder": { "pagination": { "pageSize": 1, "cursor": null }, "results": [ { "name": "AECDM", "id": "{{YOUR_ELEMENT_GROUP_ID}}" } ] } } }Show More - Record the
idvalue. Every step that follows uses it asgroupId.
To work with both 2D and 3D data, repeat this step for the other folder and record both elementGroup IDs.
Step 2: Filter Elements by Object Type
Plant 3D exposes object types through the built-in tableNames parameter:
autodesk.plant3d.parameter:tableNames-1.0.0
tableNames holds every class name in the object’s table inheritance chain, not only its concrete
class. Query it with the case-insensitive =contains= operator so that a filter matches both a
specific class and any class that inherits from it.
The AEC Data Model does not publish a catalog of Plant 3D table names. The AutoCAD Plant 3D product documentation lists the tables available to you, and the Autodesk University class Tailoring AutoCAD P&ID and AutoCAD Plant 3D introduces how the tables are organized.
This tutorial refers to the following query as GetElementsByElementGroup. Steps 2 through 5 all use
it and change only the filter variable.
- In the Query Pane, enter the following query:
Query
query GetElementsByElementGroup($groupId: ID!, $filter: ElementFilterInput, $pagination: PaginationInput) { elementsByElementGroup( elementGroupId: $groupId filter: $filter pagination: $pagination ) { pagination { pageSize cursor } results { name id properties { results { name displayValue definition { id name } } } lastModifiedOn } } }Show More - In the Query Variables Pane, enter the following values:
Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='Primary'" } }Show More - Click Play.
The limit value accepts 1 through 500 and defaults to 100. To retrieve results beyond the first
page, pass the cursor value from the response. For details, see
Pagination.
Note
Every elementsByElementGroup query in this tutorial is paginated, including those in Steps 3
through 5. A response is a complete result set only when its cursor is null. Keep passing the
returned cursor until it is null. Otherwise you risk mistaking the first page for the
complete data set.
Filter Examples
To retrieve a different object type, replace the filter variable. All values match
case-insensitively.
| Objects | Filter query |
|---|---|
| P&ID hand valves | property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='HandValves' |
| Drawings | property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='pnpdrawings' |
| Pipes (3D) | property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='Pipe,' |
| Equipment (3D) | property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='equipment' |
| Smart lines by tag | property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='Primary' and
property.id.autodesk.plant3d.parameter:tag-1.0.0=contains='4\"-CS300-P-' |
Step 3: Scope a Query to a Single Drawing
Plant 3D publishes each drawing as an element in its own right, alongside the objects the drawing
contains. An object is not tied to a single drawing, however. The same logical object can be placed on
several drawings, so Plant 3D records the object-to-drawing mapping in a separate link table,
PnPDataLinks, rather than storing a drawing ID on the object itself.
Retrieving the objects in one drawing is therefore a three-stage process:
- Stage 1. Query the
pnpdrawingsobjects to find the element that represents the drawing, and read itspnpId. - Stage 2. Query the
PnPDataLinkselements for that drawing to find the objects placed on it, and read therowIdof each one. - Stage 3. Query the object itself, matching its
pnpIdto therowIdfrom stage 2.
Stage 3 is required because a PnPDataLinks element carries only the link information. It does not
include the properties of the object it points to.
- Run the
GetElementsByElementGroupquery from Step 2 with the following variables to list the drawings in the elementGroup:Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='pnpdrawings'" } }Show MoreThe response lists the drawings together with the folders that hold them, so identify the drawing you want before you continue.
- In the response, find the drawing name in the property whose definition ID is
autodesk.plant3d.parameter:dwgName-1.0.0, and the drawing ID in the property whose definition ID isautodesk.plant3d.parameter:pnpId-1.0.0:Response
{ "name": "DWG Name", "displayValue": "1-A1-1002.dwg", "definition": { "id": "autodesk.plant3d.parameter:dwgName-1.0.0", "name": "DWG Name" } }, { "name": "ID", "displayValue": "1275", "definition": { "id": "autodesk.plant3d.parameter:pnpId-1.0.0", "name": "ID" } }Show More - Run the same query again to retrieve the link data for that drawing. Filter
tableNamesforPnPDataLinks, setdwgIdto the drawing ID from step 2, and setrowClassNameto the type of object you want. The following variables return the gate valves placed on drawing1275:Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='PnPDataLinks' and property.id.autodesk.plant3d.parameter:dwgId-1.0.0==1275 and property.id.autodesk.plant3d.parameter:rowClassName-1.0.0=='GateValve'" } }Show More - In the response, read the
rowIdof each link element from the property whose definition ID isautodesk.plant3d.parameter:rowId-1.0.0. Each value identifies one object placed on the drawing. - Retrieve the object and its properties by matching its
pnpIdto thatrowId. The following variables return the hand valve whoserowIdis577:Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='HandValve' and property.id.autodesk.plant3d.parameter:pnpId-1.0.0==577" } }Show More
The same pattern applies to 3D data. Filter the 3D elementGroup for pnpdrawings to get the piping
drawing ID, then query PnPDataLinks with that dwgId and a rowClassName such as Pump.
The following variables return the pumps placed on the piping drawing whose ID is 4346:
Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:tableNames-1.0.0=contains='PnPDataLinks' and property.id.autodesk.plant3d.parameter:dwgId-1.0.0==4346 and property.id.autodesk.plant3d.parameter:rowClassName-1.0.0=='Pump'" } }Show More
As in the 2D flow, these link elements carry only link information. Read each rowId and query the
object itself to retrieve its properties.
Step 4: Query Custom Properties
When a Plant 3D Collaboration project defines custom properties, the AEC Data Model generates a custom parameter for each one and stores it in a parameter collection under the related hub.
The ID format for a custom parameter differs from the format for a built-in parameter. Using the built-in format for a custom property is the most common cause of a filter that returns no results.
| Parameter kind | ID format | Example |
|---|---|---|
| Built-in | autodesk.plant3d.parameter:{name}-{version} |
autodesk.plant3d.parameter:pnpClassName-1.0.0 |
| Custom | parameters.{hubId}:{propertyName}_{type}-{version} |
parameters.{{YOUR_HUB_ID}}:testnumeric_double-1.0.0 |
The custom format inserts a _{type} segment, such as _double, before the version. The built-in
format has no equivalent segment.
Discover the Parameter ID
Because the _{type} segment depends on how the property was defined, do not assemble a custom
parameter ID by hand. Query for the ID first, then use the value the response returns.
- In the Query Pane, enter the following query:
Query
query propertyDefinitionsByElementGroup($elementGroupId: ID!, $filter: PropertyDefinitionFilterInput, $pagination: PaginationInput) { propertyDefinitionsByElementGroup( elementGroupId: $elementGroupId filter: $filter pagination: $pagination ) { pagination { cursor pageSize } results { id name } } }Show More - In the Query Variables Pane, name the custom property you are looking for:
Query Variables
{ "elementGroupId": "{{YOUR_ELEMENT_GROUP_ID}}", "filter": { "names": ["testnumeric"] }, "pagination": { "limit": 100 } }Show More - Click Play, and record the
idvalue from the response. It uses the custom format shown in the preceding table. Use that exact value in your filter.
For more on this query, see propertyDefinitionsByElementGroup.
Filter on the Custom Property
To retrieve elements whose custom testnumeric property equals 66, run the
GetElementsByElementGroup query from Step 2 with the following variables:
Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.parameters.{{YOUR_HUB_ID}}:testnumeric_double-1.0.0=='66'" } }Show More
Step 5: Query Relationship Data
Query relationship tables through the pnpClassName parameter rather than tableNames:
autodesk.plant3d.parameter:pnpClassName-1.0.0
Use either the =contains= or the == operator with the relationship table name. To retrieve rows
from the LineInlineAsset relationship table, run the GetElementsByElementGroup query from Step 2
with the following variables:
Query Variables
{ "groupId": "{{YOUR_ELEMENT_GROUP_ID}}", "pagination": { "limit": 100, "cursor": null }, "filter": { "query": "property.id.autodesk.plant3d.parameter:pnpClassName-1.0.0=contains='LineInlineAsset'" } }Show More
Note
tableNames and pnpClassName are not interchangeable. Use tableNames to filter design
objects by type, because it matches the entire inheritance chain. Use pnpClassName to query
relationship tables.
Plant 3D Parameter Reference
This tutorial uses the following built-in parameters:
| Parameter | ID | Description |
|---|---|---|
tableNames |
autodesk.plant3d.parameter:tableNames-1.0.0 |
Class inheritance chain. Filters objects by type. |
pnpClassName |
autodesk.plant3d.parameter:pnpClassName-1.0.0 |
Concrete class name. Queries relationship tables. |
pnpId |
autodesk.plant3d.parameter:pnpId-1.0.0 |
ID of the object in the Plant 3D project database. |
dwgId |
autodesk.plant3d.parameter:dwgId-1.0.0 |
On a PnPDataLinks element, the drawing the object is
placed on. |
rowClassName |
autodesk.plant3d.parameter:rowClassName-1.0.0 |
On a PnPDataLinks element, the class of the linked
object. Selects an object type within a drawing. |
rowId |
autodesk.plant3d.parameter:rowId-1.0.0 |
On a PnPDataLinks element, the pnpId of the linked
object. |
dwgName |
autodesk.plant3d.parameter:dwgName-1.0.0 |
File name of a drawing. |
tag |
autodesk.plant3d.parameter:tag-1.0.0 |
Tag assigned to the object in Plant 3D. |
Next Steps
- Combine multiple conditions in one filter with Advanced Filtering Using RSQL.
- Review the field-based filter syntax in Standard Filtering.
- Retrieve results beyond the first page using Pagination.
- Explore the full query surface in the elementsByElementGroup reference.