.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I access subobject in Plant3d from CSharp?

1 REPLY 1
Reply
Message 1 of 2
cqhs
582 Views, 1 Reply

How can I access subobject in Plant3d from CSharp?

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.

 

1 REPLY 1
Message 2 of 2
cqhs
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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost