Change sheet metal styles from an assembly for selected parts.

Change sheet metal styles from an assembly for selected parts.

anilkumar279
Enthusiast Enthusiast
871 Views
3 Replies
Message 1 of 4

Change sheet metal styles from an assembly for selected parts.

anilkumar279
Enthusiast
Enthusiast

hi,

I want to set sheet metal active style from with help of input list box.

 

assembly 999-A.iam

Sub assembly 999-B.iam

Part in sub assembly

999-1.ipt

999-2.ipt

999-3.ipt

999-4.ipt

 

 only for -1,-2 & -3 ipt.

Please help me.

 

SyntaxEditor Code Snippet

oCompDef = ThisDoc.Document.ComponentDefinition
oAssyOccurrences  = oCompDef.Occurrences
Dim oOccurrence As ComponentOccurrence
Dim oSubOccurrence1 As ComponentOccurrence
For Each oOccurrence In oAssyOccurrences
If oSubOccurrence.Definition.Document = "999-1.ipt" AndAlso platte_selected = "4 mm" Then


oSubOccurrence.SheetMetal.SetActiveStyle ="_4 mm S355MC"

 

0 Likes
Accepted solutions (1)
872 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @anilkumar279,

 

In the previous code, what is meaning of "platte_selected = "4 mm"".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

anilkumar279
Enthusiast
Enthusiast

Hi, I have a input list box this comes from there.

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @anilkumar279,

 

Try the following iLogic code. Needs some modification based on your situation.

 

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition

Dim oSheetDef As SheetMetalComponentDefinition
Dim oStyle As SheetMetalStyle

For Each occ As ComponentOccurrence In oDef.Occurrences.AllLeafOccurrences
    If occ.Definition.Document.DisPlayName = "999-1.ipt" AndAlso platte_selected = "4 mm" Then
        oSheetDef = occ.Definition
        For Each oStyle In oSheetDef.SheetMetalStyles
            If oStyle.Name = "_4 mm S355MC" Then
                oStyle.Activate()
            End If
        Next
    ElseIf occ.Definition.Document.DisplayName = "999-2.ipt" AndAlso platte_selected = "5 mm" Then
        oSheetDef = occ.Definition
        For Each oStyle In oSheetDef.SheetMetalStyles
            If oStyle.Name = "_5 mm S355MC" Then
                oStyle.Activate()
            End If
        Next
    ElseIf occ.Definition.Document.DisplayName = "999-3.ipt" AndAlso platte_selected = "6 mm" Then
        oSheetDef = occ.Definition
        For Each oStyle In oSheetDef.SheetMetalStyles
            If oStyle.Name = "_6 mm S355MC" Then
                oStyle.Activate()
            End If
        Next
    End If
Next

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes