Autocad Plant 3D - Get selected Nozzles in the drawing using .NET

Autocad Plant 3D - Get selected Nozzles in the drawing using .NET

Anonymous
Not applicable
1,522 Views
4 Replies
Message 1 of 5

Autocad Plant 3D - Get selected Nozzles in the drawing using .NET

Anonymous
Not applicable

Hello,

 

I am trying to get the ObjectIds for the nozzle selected in a Plant 3D drawing. I use the following code to get the selected objects:

 

// This is the current document:

Autodesk.AutoCAD.ApplicationServices.Document document;

 

// This is the current Autocad project:

Autodesk.ProcessPower.ProjectManager.Project project;

 

PromptSelectionResult selectionResult = document.Editor.SelectImplied();
SelectionSet set = selectionResult.Value;

ObjectId[] idList = set.GetObjectIds();
foreach (ObjectId id in idList)
{

   // This shows the selected object (its class name)
   Console.WriteLine("Selected class = " + project.DataLinksManager.GetObjectClassname(id));
}

 

The code above works fine when I select an Equipment for example. However, if I select a Nozzle (using the CTRL key) the code above still returns the ObjectId of the parent Equipment, and not the Nozzle itself. I can confirm that the Nozzle is selected, because when I right click and select properties, Autocad shows the properties of the Nozzle.

 

I also tried the code below, but it doesn't work either.

 

foreach (SelectedObject selectedObject in set)
{

   SelectedSubObject[] subEntities = selectedObject.GetSubentities();

   foreach (SelectedSubObject entity in subEntities)
   {
      ObjectId[] ids = entity.FullSubentityPath.GetObjectIds();
      if (ids != null)
      {

         foreach (ObjectId id in ids)
         {

            // This still returns the Equipment, and not the Nozzle
            Console.WriteLine("Selected class = " + project.DataLinksManager.GetObjectClassname(id));
         }

     }

   }

}

 

Any help would be much apprectiated.

 

Thank you,

 

Mihail

0 Likes
1,523 Views
4 Replies
Replies (4)
Message 2 of 5

Jsuffet
Participant
Participant

Anyone?  

 

I'm having the same issue.

 

The user selects the entity and it will always return the Vessel.  I can get the nozzles from the Vessel but i dont know which is selected.  Is there a straight forward way to get which nozzle was selected?

 

Thank you

Jeff

0 Likes
Message 3 of 5

jabowabo
Mentor
Mentor

You'll need to get the selected item as an 'Equipment' object. From it you can get the NozzleSubPartCollection, iterate each NozzleSubPart to get the ports and their locations. 

Use a Editor.PointMonitor to get the selected location and compare with the nozzle port locations to determine which was selected. Not a straightforward process but it's doable.

0 Likes
Message 4 of 5

Jsuffet
Participant
Participant

A little convoluted and definitely not what i was hoping for but doable.

 

Thank you,

Jeff

0 Likes
Message 5 of 5

sepehr_taherpour
Explorer
Explorer

I have only AllSubParts on my equipment and what is the case when even that is empty? Have I created my equipments/nozzles in a wrong way?

0 Likes