04-12-2022
06:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-12-2022
06:49 PM
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
Or if this helped you, please, click (like)
Regards
Alan