• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Member
    cqhs
    Posts: 4
    Registered: ‎12-21-2011

    How can I access subobject in Plant3d from CSharp?

    92 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.

     

    Please use plain text.
    Member
    cqhs
    Posts: 4
    Registered: ‎12-21-2011

    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?

    Please use plain text.