Autocad Plant 3D - Get selected Nozzles in the drawing using .NET
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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