.NET

.NET

Reply
Member
cqhs
Posts: 4
Registered: ‎12-21-2011
Message 1 of 2 (226 Views)

How can I access subobject in Plant3d from CSharp?

226 Views, 1 Replies
11-20-2012 05:24 AM

I have a program in C# where i am trying to access a sub-object which is of type Connectors/fasteners.

 

In a drawing, I have an object with class (PnPClassname) P3dConnector, and when I click on it's red circle with <ctrl> pressed, I access an object with class (PnPClassname) BoltSet. I have added the event oDatabase.ObjectModified, but this only access the P3dConnector-object, not the BoltSet-object. See the image and attached file.

 

How can i access this sub-object? I have tried to loop through prompted result set using SelectAll. The P3dConnector-object is listed but not the BoltSet-object.

 

Member
cqhs
Posts: 4
Registered: ‎12-21-2011
Message 2 of 2 (192 Views)

Re: How can I access subobject in Plant3d from CSharp?

11-21-2012 01:45 AM in reply to: cqhs

I am able to access the object by using following code:

  using (Transaction tx = objId.Database.TransactionManager.StartTransaction())
  {
    DBObject dbObject = tx.GetObject(objId, OpenMode.ForRead);
    Autodesk.ProcessPower.PnP3dObjects.Connector Conn = tx.GetObject(objId, OpenMode.ForRead) as Autodesk.ProcessPower.PnP3dObjects.Connector;

    if (Conn != null)
    {
      foreach(Autodesk.ProcessPower.PnP3dObjects.SubPart sp in Conn.AllSubParts)
      {
        MessageBox.Show(sp.GetType().ToString());
      }
    }
  }

But the Conn.Id is 0. How do i get the object from a sub part?

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.