I would like to let my users to select an entity in the Ortho view in AutoCAD Plant 3D and find some properties of this selected equipment:
But it seems that to do this I need to find the corresponding object in the 3D model first:
How can I do this?
Unfortunately, the current Plant SDK does not provide this functionality. But a good news is that there is an undocumented class that is safe to use for this purpose.
Before we start coding, we need to find some sample drawings which we can use for testing. Let it be the out-of-the-box SampleProject with its Area1_Plan drawing:
and the 3D model in 1-PE-001 drawing:
Screenshots from these files can be found at the top of this post.
Let’s start from selecting an entity in the Ortho view. When you test the code, do not forget to switch from PAPER space to MODEL using the button shown on the first screenshot (or you just can’t select anything).
As soon as we have the selected entity’s ObjectId, we can call the undocumented method
It is located in an assembly called C:\Program Files\Autodesk\AutoCAD 2014\PLNT3D\PnPDwg2dUtil.dll and, obviously, we need to add a reference to it from our Visual Studio project.
This is a code snippet which demonstrates usage of the GetModelObjectId() method. It defines a new command called “FOTM” (From Ortho To Model):
// From an entity in Ortho, looking for this entity in the Model.
// Using the out-of-the-box SampleProject for tests:
// Ortho: Area1_Plan
// Model: 1-PE-001
// In Area1_Plan, you need to switch from Paper to Model,
// otherwise you can't select anything in it.
public void FromOrthoToModel()
// To test, select an entity in an Ortho drawing
Document doc = Application.DocumentManager.MdiActiveDocument;
PromptEntityResult selectedEntity = doc.Editor.GetEntity(
"\nSelect an entity to annotate:");
if (selectedEntity.Status != PromptStatus.OK)
// GetModelObjectId() is an undocumented method to find
// the corresponding entity in the Piping Model
Autodesk.ProcessPower.Drawings2d.MdObjectId orthoId =
// In this orthoId we have a drawing GUID and PpObjectId:
Autodesk.ProcessPower.DataLinks.PpObjectId ppId =
string dwgGUID = orthoId.DwgGUID;
// Find the entity's ObjectId in the Model drawing.
// Note: To do this you have to have the Model drawing open.
Autodesk.ProcessPower.DataLinks.DataLinksManager dlm =
ObjectId oid = dlm.MakeAcDbObjectId(ppId);
// THAT'S IT:
doc.Editor.WriteMessage("\n oid=" + oid.ToString());
} // FromOrthoToModel()