03-23-2022
09:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-23-2022
09:26 AM
What version of Inventor are you using? Try this version of your code. I changed a few thing around, and I am using a fairly new tool to direct all those vague iLogic snippets to the proper document reference. If you have any questions about any of this, feel free to ask them.
Sub Main()
Dim thisAssyDoc As AssemblyDocument = CType(ThisDoc.Document, AssemblyDocument)
AddCusProp(thisAssyDoc)
End Sub
Sub AddCusProp(assemblyDoc As AssemblyDocument)
For Each subCompOcc As ComponentOccurrence In assemblyDoc.ComponentDefinition.Occurrences
If subCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
AddCusProp(subCompOcc.Definition.Document)
End If
If Not TypeOf subCompOcc.Definition Is SheetMetalComponentDefinition Then Continue For
Dim oscCompDef As SheetMetalComponentDefinition = subCompOcc.Definition
Dim ActiveStyle As SheetMetalStyle = oscCompDef.ActiveSheetMetalStyle
ChangeStyleToNewOne(oscCompDef.Document, ActiveStyle)
Next
End Sub
Sub ChangeStyleToNewOne(oSMDoc As PartDocument, ActiveStyle As SheetMetalStyle)
Dim SOP = StandardObjectFactory.Create(oSMDoc)
If ActiveStyle.Name = "10ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("10ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "10ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("10ga GA Jkt (Test)")
ElseIf ActiveStyle.Name = "10ga SS 304L Solid" Then
SOP.SheetMetal.SetActiveStyle("10ga SS 304L Solid (Test)")
ElseIf ActiveStyle.Name = "12ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("12ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "12ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("12ga GA Jkt (Test)")
ElseIf ActiveStyle.Name = "14ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("14ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "14ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("14ga GA Jkt (Test)")
ElseIf ActiveStyle.Name = "14ga SS 304L Solid" Then
SOP.SheetMetal.SetActiveStyle("14ga SS 304L Solid (Test)")
ElseIf ActiveStyle.Name = "16ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("16ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "16ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("16ga GA Jkt (Test)")
ElseIf ActiveStyle.Name = "16ga SS 304L Solid" Then
SOP.SheetMetal.SetActiveStyle("16ga SS 304L Solid (Test)")
ElseIf ActiveStyle.Name = "18ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("18ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "18ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("18ga GA Jkt (Test)")
ElseIf ActiveStyle.Name = "18ga SS 304L Solid" Then
SOP.SheetMetal.SetActiveStyle("18ga SS 304L Solid (Test)")
ElseIf ActiveStyle.Name = "20ga GA Brt" Then
SOP.SheetMetal.SetActiveStyle("20ga GA Brt (Test)")
ElseIf ActiveStyle.Name = "20ga GA Jkt" Then
SOP.SheetMetal.SetActiveStyle("20ga GA Jkt (Test)")
Else
SOP.SheetMetal.SetActiveStyle("Default")
SOP.iProperties.Value("Project", "Stock Number") = "Material no disponible para tolerancias"
SOP.iProperties.Value("Project", "Description") = "Material no disponible para tolerancias"
End If
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)