PPT_LOGO_4b
‹#›
Autodesk Confidential Information January 2010
Sheet Metal Styles
•Sheet metal styles and unfold methods provide a way of defining and saving various settings.
•
•Activating a sheet metal style causes the values defined in the style to be applied to the sheet metal document.
•
•These values are accessed through the SheetMetalStyle object using its properties:
§BendRadius, BendReliefDepth,
BendReliefWidth, CornerReliefSize,
GapSize, Thickness, …
§
•These properties are get/set as Strings
•
    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    '// Use:
    '// [Sheet Metal Style Creation Example (Visual Basic)]
    '// This sample illustrates creating a new sheet metal style.
    '// It uses a sample bend table delivered with Inventor. You can
    '// edit the path below to reference any existing bend table.
    '// To use the sample make sure a bend table is available at the
    '// specified path, open a sheet metal document, and run the sample.
    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Public Sub CreateSheetMetalStyle()

        ' Set a reference to the sheet metal document.
        ' This assumes a part document is active.
        Dim oPartDoc As PartDocument
        oPartDoc = _InvApplication.ActiveDocument

        ' Make sure the document is a sheet metal document.
        If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            MsgBox("A sheet metal document must be open.")
            Exit Sub
        End If

        ' Get the sheet metal component definition. Because this is a part document whose
        ' sub type is sheet metal, the document will return a SheetMetalComponentDefinition
        ' instead of a PartComponentDefinition.
        Dim oSheetMetalCompDef As SheetMetalComponentDefinition
        oSheetMetalCompDef = oPartDoc.ComponentDefinition

        ' Copy a sheet metal style to create a new one. There will always be at least
        ' one style in a document. This sample uses the first style, which is the default.
        Dim oStyle As SheetMetalStyle

        Try
            oStyle = oSheetMetalCompDef.SheetMetalStyles.Copy(oSheetMetalCompDef.SheetMetalStyles.Item(1), "Custom Style")
        Catch
            MsgBox("Custom Style already exists :(")
            Exit Sub
        End Try

        ' Get the name of the parameter used for the thickness. We need the actual name
        ' to use in expressions to set the other values. It's best to get the name rather
        ' than hard code it because the name changes with various languages and the user
        ' can change the name in the Parameters dialog.

        ' This gets the name of the thickness from the component definition.
        Dim sThicknessName As String
        sThicknessName = oSheetMetalCompDef.Thickness.Name

        ' Set the various values associated with the style.
        oStyle.BendRadius = sThicknessName & " * 1.5"
        oStyle.BendReliefWidth = sThicknessName & " / 2"
        oStyle.BendReliefDepth = sThicknessName & " * 1.5"
        oStyle.CornerReliefSize = sThicknessName & " * 2.0"
        oStyle.MinimumRemnant = sThicknessName & " * 2.0"

        oStyle.BendReliefShape = BendReliefShapeEnum.kRoundBendReliefShape
        oStyle.BendTransition = BendTransitionEnum.kArcBendTransition
        oStyle.CornerReliefShape = CornerReliefShapeEnum.kRoundCornerReliefShape

        ' Add a linear unfold method.  Unfold methods are now separate
        ' from sheet metal styles.
        Try
            oSheetMetalCompDef.UnfoldMethods.AddLinearUnfoldMethod("Linear Sample", "0.43")
        Catch
            MsgBox("Linear Sample UnfoldMethod already exists :(")
            Exit Sub
        End Try

        ' Add a bend table fold method. This uses error trapping to catch if an
        ' invalid bend table file was specified.
        Try
            Call oSheetMetalCompDef.UnfoldMethods.AddBendTableFromFile("Table Sample", OpenFile("Bend Table (*.txt)|*.txt"))
        Catch
            MsgBox("Unable to load bend table")
        End Try

        ' Make the new linear method the active unfold method for the document.
        Dim oUnfoldMethod As UnfoldMethod
        oUnfoldMethod = oSheetMetalCompDef.UnfoldMethods.Item("Linear Sample")
        oStyle.UnfoldMethod = oUnfoldMethod

        ' Activate this style, which will also update the part.
        oStyle.Activate()

    End Sub

    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    '// Use:
    '// This sample illustrates getting information about sheet metal styles,
    '// unfold methods, and thickness.
    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Public Sub SheetMetalStyleDisplay()

        ' Set a reference to the sheet metal document.
        ' This assumes a part document is active.
        Dim oPartDoc As PartDocument
        oPartDoc = _InvApplication.ActiveDocument

        ' Make sure the document is a sheet metal document.
        If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            MsgBox("A sheet metal document must be open.")
            Exit Sub
        End If

        ' Get the sheet metal component definition. Because this is a part document whose
        ' sub type is sheet metal, the document will return a SheetMetalComponentDefinition
        ' instead of a PartComponentDefinition.
        Dim oSheetMetalCompDef As SheetMetalComponentDefinition
        oSheetMetalCompDef = oPartDoc.ComponentDefinition

        ' Iterate through the sheet metal styles.
        Dim oStyle As SheetMetalStyle
        For Each oStyle In oSheetMetalCompDef.SheetMetalStyles

            ' Display information about the style.
            If oStyle Is oSheetMetalCompDef.ActiveSheetMetalStyle Then
                Debug.Print("** Active SheetMetal Style **")
            End If

            Debug.Print("Name: " & oStyle.Name)
            Debug.Print(" Bend Radius: " & oStyle.BendRadius)
            Debug.Print(" Bend Relief Depth: " & oStyle.BendReliefDepth)
            Debug.Print(" Bend Relief Width: " & oStyle.BendReliefWidth)

            Select Case oStyle.BendReliefShape
                Case BendReliefShapeEnum.kDefaultBendReliefShape
                    Debug.Print(" Bend Relief Shape: Default")
                Case BendReliefShapeEnum.kRoundBendReliefShape
                    Debug.Print(" Bend Relief Shape: Round")
                Case BendReliefShapeEnum.kStraightBendReliefShape
                    Debug.Print(" Bend Relief Shape: Straight")
                Case BendReliefShapeEnum.kTearBendReliefShape
                    Debug.Print(" Bend Relief Shape: Tear")
            End Select

            Select Case oStyle.BendTransition
                Case BendTransitionEnum.kDefaultBendTransition
                    Debug.Print(" Bend Transition: Default")
                Case BendTransitionEnum.kArcBendTransition
                    Debug.Print(" Bend Transition: Arc")
                Case BendTransitionEnum.kIntersectionBendTransition
                    Debug.Print(" Bend Transition: Intersection")
                Case BendTransitionEnum.kNoBendTransition
                    Debug.Print(" Bend Transition: No Bend")
                Case BendTransitionEnum.kStraightLineBendTransition
                    Debug.Print(" Bend Transition: Straight Line")
                Case BendTransitionEnum.kTrimToBendBendTransition
                    Debug.Print(" Bend Transition: Trom to Bend")
            End Select

            Select Case oStyle.CornerReliefShape
                Case CornerReliefShapeEnum.kDefaultCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Default")
                Case CornerReliefShapeEnum.kRoundCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Round")
                Case CornerReliefShapeEnum.kSquareCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Square")
                Case CornerReliefShapeEnum.kTearCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Tear")
                Case CornerReliefShapeEnum.kArcWeldCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Arc Weld")
                Case CornerReliefShapeEnum.kFullRoundCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Full Found")
                Case CornerReliefShapeEnum.kIntersectionCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Intersection")
                Case CornerReliefShapeEnum.kLinearWeldReliefShape
                    Debug.Print(" Corner Relief Shape: Linear Weld")
                Case CornerReliefShapeEnum.kTrimToBendReliefShape
                    Debug.Print(" Corner Relief Shape: Trim to Bend")
                Case CornerReliefShapeEnum.kNoReplacementCornerReliefShape
                    Debug.Print(" Corner Relief Shape: No Replacement")
                Case CornerReliefShapeEnum.kRoundWithRadiusCornerReliefShape
                    Debug.Print(" Corner Relief Shape: Round with Radius")
            End Select

            Debug.Print(" Corner Relief Size: " & oStyle.CornerReliefSize)
            Debug.Print(" Minimum Remnant: " & oStyle.MinimumRemnant)

            Debug.Print(" Thickness: " & oStyle.Thickness)

            Debug.Print(" -------------------------- ")

        Next

        ' Display information about the unfold methods.
        Debug.Print("")
        Debug.Print("Unfold Methods")
        Dim oUnfoldMethod As UnfoldMethod
        For Each oUnfoldMethod In oSheetMetalCompDef.UnfoldMethods
            Debug.Print(" " & oUnfoldMethod.Name)
            Select Case oUnfoldMethod.UnfoldMethodType
                Case UnfoldMethodTypeEnum.kBendTableUnfoldMethod
                    Debug.Print(" Unfold Method Type: Bend Table")
                Case UnfoldMethodTypeEnum.kLinearUnfoldMethod
                    Debug.Print(" Unfold Method Type: Linear")
                    Debug.Print(" Value: " & oUnfoldMethod.kFactor)
                Case UnfoldMethodTypeEnum.kCustomEquationUnfoldMethod
                    Debug.Print(" Unfold Method Type: Custom Equation")
            End Select

            Debug.Print(" -------------------------- ")
        Next

    End Sub

    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    '// Use: This sample illustrates editing the thickness of a sheet metal part
    '//
    '/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Public Sub SetSheetMetalThickness()

        ' Set a reference to the sheet metal document.
        ' This assumes a sheet metal document is active.
        Dim oPartDoc As PartDocument
        oPartDoc = _InvApplication.ActiveDocument

        ' Get the sheet metal component definition. Because this is a part document whose
        ' sub type is sheet metal, the document will return a SheetMetalComponentDefinition
        ' instead of a PartComponentDefinition.
        Dim oSheetMetalCompDef As SheetMetalComponentDefinition
        oSheetMetalCompDef = oPartDoc.ComponentDefinition

        ' Change Thickness
        oSheetMetalCompDef.ActiveSheetMetalStyle.Thickness = "0.50 in"

        ' Update the part.
        _InvApplication.ActiveDocument.Update()

    End Sub