FlatPattern Extents

By Vladimir Ananyev

Q:  I need to get the extents of the FlatPattern Sheet Metal part. In the User Interface I can right click on the FlatPattern feature and select "Extents". Is there a way to get the extents using the API?

A:  There is not an API method that directly gets the FlatPattern extents. However this can be calculated. Here is a VBA example:

Public Sub SheetMetalExtents()

 

    Dim oDoc As PartDocument

    Set oDoc = ThisApplication.ActiveDocument

   

    Dim oSMDef As SheetMetalComponentDefinition

    Set oSMDef = oDoc.ComponentDefinition

   

    Dim oRange As Box

    Set oRange = oSMDef.FlatPattern.Body.RangeBox

   

    Dim dblXSize As Double, dblYSize As Double

    Dim oMax As Point, oMin As Point

    

    Set oMax = oRange.MaxPoint

    Set oMin = oRange.MinPoint

   

    dblXSize = oMax.x – oMin.x

    dblYSize = oMax.y – oMin.y

    MsgBox "Sheet metal extents: " & _

       vbNewLine & vbNewLine & _

       FormatNumber(dblXSize, 3) & " cm x " & _

       FormatNumber(dblYSize, 3) & " cm" & _

       vbNewLine & vbNewLine & _

       FormatNumber(dblXSize / 2.54, 3) & " in x " & _

       FormatNumber(dblYSize / 2.54, 3) & " in"

<

p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNormal”>  End Sub


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading