Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Here is a working code to change the style of level one occurrences in an assembly. If the sheetmetal parts are in a subassembly you will need additional code to detect an assembly and iterate through those as well. 

 

Sub Main()
Dim thisAssyDoc As AssemblyDocument = CType(ThisDoc.Document, AssemblyDocument)
ChangeToTest(thisAssyDoc)
End Sub

Sub ChangeToTest(assemblyDoc As AssemblyDocument)

For Each subCompOcc As ComponentOccurrence In assemblyDoc.ComponentDefinition.Occurrences
	Dim oCompDef As ComponentDefinition = subCompOcc.Definition
	If TypeOf oCompDef Is SheetMetalComponentDefinition Then
		oCompDef = subCompOcc.Definition
		Try
		oCompDef.SheetMetalStyles.Item("18ga GA JKT (Test)").Activate
		Catch
			MessageBox.Show("Fail to find Style", "Title")
		End Try
	Else
		MessageBox.Show("Fail", "Title")
	End If
Next

End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan