.NET

.NET

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

How can I access subobject in Plant3d from CSharp?

250 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 (216 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?

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.