.NET

Reply
Contributor
_ane_
Posts: 19
Registered: ‎09-03-2010
Message 1 of 2 (102 Views)
Accepted Solution

Get position and bounding box of a BOM table

102 Views, 1 Replies
06-27-2014 02:08 AM

Hello,

 

I need to get the position and boundig box of the table "bill of materials". Any idea?

 

  Public Shared Sub GetPosicionBOM()
    Dim acadApp As AcadApplication = Nothing
    Dim symMgr As McadSymbolBBMgr = Nothing
    Dim symBOMs As McadBOMs = Nothing

    acadApp = DirectCast(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)
    symMgr = acadApp.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr")
    symBOMs = symMgr.BOMMgr.GetAllBOMTables(True)


    If symBOMs IsNot Nothing AndAlso symBOMs.Count > 0 Then
      For Each symBOM As McadBOM In symBOMs

        ' I neet to get the position and bounding box of the object symBOM

      Next
    End If

    acadApp = Nothing
    symMgr = Nothing
    symBOMs = Nothing
  End Sub

 

thansk,

 

Ane

Contributor
_ane_
Posts: 19
Registered: ‎09-03-2010
Message 2 of 2 (65 Views)

Re: Get position and bounding box of a BOM table

06-30-2014 03:36 AM in reply to: _ane_

 

Finally I found the solution;

 

  <CommandMethod("PartListBoundingBox")> _
  Public Sub PartListBoundingBox()
    Dim doc As Document = Application.DocumentManager.MdiActiveDocument
    Dim bt As BlockTable = Nothing
    Dim btr As BlockTableRecord = Nothing
    Dim objId As ObjectId = Nothing
    Dim partList As Entity = Nothing

    Using tr As Transaction = doc.TransactionManager.StartTransaction

      bt = DirectCast(tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead), BlockTable)
      btr = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead), BlockTableRecord)

      If btr IsNot Nothing Then
        For Each objId In btr
          If objId.ObjectClass.DxfName.ToUpper = "ACMPARTLIST" Then

            partList = tr.GetObject(objId, OpenMode.ForRead)
            If partList.Bounds.HasValue Then
              MsgBox("MinPoint (" & partList.Bounds.Value.MinPoint(0).ToString & "," & partList.Bounds.Value.MinPoint(1) & ")" & Chr(13) & _
                          "MaxPoint (" & partList.Bounds.Value.MaxPoint(0).ToString & "," & partList.Bounds.Value.MaxPoint(1) & ")")
              Exit For
            End If
          End If
        Next
      End If

      tr.Commit()
    End Using

  End Sub

 

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.