Plant 3D RowID to Asset

Plant 3D RowID to Asset

johan_germishuys
Contributor Contributor
593 Views
6 Replies
Message 1 of 7

Plant 3D RowID to Asset

johan_germishuys
Contributor
Contributor

Hi,

 

I'm currently working on a project to extract various types of relational data from PID. I'm able to get the "ControlValve" table, and iterate over them. But i'm struggling to figure out how to go from PnPRow to "Asset". 

 

Asset allows me to go through the various linesegments and associated assets. Any help would be greatly appreciated.

 

Dim pPnPDb As PnPDatabase = m_dlm.GetPnPDatabase()
Dim table As PnPTable = pPnPDb.Tables("ControlValve")
Dim rows As PnPRow() = table.Select()
Dim r As PnPRow, MPL As New ObservableCollection(Of String)

For Each r In rows
     Dim properties As List(Of KeyValuePair(Of String, String))
     properties = m_dlm.GetAllProperties(r.RowId, True)

 

    For Each oID In oAsset.LineSegmentIds

       Do Stuff....

    Next

 

Next

 

0 Likes
Accepted solutions (1)
594 Views
6 Replies
Replies (6)
Message 2 of 7

E-Bim
Autodesk
Autodesk

Hello @johan_germishuys ,

I think you can do what you want using the snippet described in this AutoCAD DevBlog article:  Plant SDK: Get ObjectID by PnPID - AutoCAD DevBlog

You will see it is possible to find the objectId of a plant 3D object from its RowId (which is the same than its PnPID.

The only thing you have to be careful of is that multiple AcDbObjectIds may be link to a single RowID. So in your code you have probably to do few checks to find out if for 1 RwoId you will get 1 or several AcDbObjectIds.

Let me know if this can help.

Regards.

Emmanuel.

Emmanuel
0 Likes
Message 3 of 7

johan_germishuys
Contributor
Contributor

Hi,

 

This solution is something I've tried. I'm not selecting an object inside a drawing.

 

I'm trying to get this information for a drawing that might not be open.

0 Likes
Message 4 of 7

E-Bim
Autodesk
Autodesk
Hello Johan,
In that case I have few questions:

* Would you like to access the data with AutoCAD Plant 3D not running on your computer?
* If AutoCAD is running, will it be acceptable to open the drawing in which the asset resides?
* Or you try to access the data completely outside of AutoCAD Plant 3D?
Regards.
Emmanuel
0 Likes
Message 5 of 7

jabowabo
Mentor
Mentor
Accepted solution

@johan_germishuys wrote:

I'm currently working on a project to extract various types of relational data from PID. I'm able to get the "ControlValve" table, and iterate over them. But i'm struggling to figure out how to go from PnPRow to "Asset". 

 

Asset allows me to go through the various linesegments and associated assets. Any help would be greatly appreciated.


 

You can use the database relationship tables to get related row IDs without needing get items as Assets - see examples below. If you really want to get them as Assets, you can use the PnPDataLinks table to find item handles from rowIds, then convert the handle to an objectId.

// format: GetRelatedRowIds("<tableName>", "<colName1>", rowId, "<colName2>");

// example1 - returns asset rowIds owned by a line segment:
GetRelatedRowIds("LineInlineAsset", "Line", lineRowId, "Asset");

// example2 - returns line segment rowId that owns and asset:
GetRelatedRowIds("LineInlineAsset", "Asset", assetRowId, "Line");

 

 

 

Message 6 of 7

johan_germishuys
Contributor
Contributor
Thank you, I've gone about using these. Really appreciate the help and direction.
0 Likes
Message 7 of 7

johan_germishuys
Contributor
Contributor

How would I go about using this in the API to return results ?

 

SELECT LSA.Line AS Line, LEA.Asset AS 'TO'

FROM LineStartAsset_PNP AS LSA

LEFT JOIN LineEndAsset_PNP AS LEA ON LEA.Line = LSA.Line

WHERE LSA.Asset = 148816 And LEA.Asset NOT IN (148816,148610)

 

UNION ALL

 

SELECT LEA.Line AS Line, LSA.Asset AS 'TO'

FROM LineEndAsset_PNP AS LEA

LEFT JOIN LineStartAsset_PNP AS LSA ON LSA.Line = LEA.Line

WHERE LEA.Asset = 148816 And LSA.Asset NOT IN (148816,148610)

0 Likes