Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Neuzzo
in reply to: Cadkunde.nl

I've modify with your suggest, all work but sheetmetalstyles no.

 

 

Dim oDoc As PartDocument = ThisDoc.Document
If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oSheetMetalComponentDef As Inventor.SheetMetalComponentDefinition = oDoc.ComponentDefinition

Select Case Materiale
Case iProperties.Material = "811151 AISI 304 sp. 0.8 SB + PVC", iProperties.Material = "811503 AISI 430 sp. 0.8 2B", iProperties.Material = "811531 AISI 430 sp. 0.8 SB + PVC", iProperties.Material = "811535 AISI 430 sp. 0.8 SB + PVC"
		oSheetMetalComponentDef.SheetMetalStyles.Item("8/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod

Case iProperties.Material = "801171 AISI 304 sp.1 2B", iProperties.Material = "811175 AISI 304 sp. 1 SB + PVC", iProperties.Material = "811541 AISI 430 sp. 1 SB + PVC", iProperties.Material = "811547 AISI 430 sp. 1 BA"
		oSheetMetalComponentDef.SheetMetalStyles.Item("10/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "801181 AISI 304 sp. 1.2 2B", iProperties.Material = "811181 AISI 304 sp. 1.2 SB + PVC"
		oSheetMetalComponentDef.SheetMetalStyles.Item("12/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("12/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811191 AISI 304 sp. 1.5 SB + PVC", iProperties.Material = "811505 AISI 430 sp. 1.5 2B", iProperties.Material = "811585 AISI 430 sp. 1.5 BA + PVC"
		oSheetMetalComponentDef.SheetMetalStyles.Item("15/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod

Case iProperties.Material = "801211 AISI 304 sp. 2 2B", iProperties.Material = "811194 AISI 304 sp. 2 SB + PVC", iProperties.Material = "811507 AISI 430 sp. 2 BA"
		oSheetMetalComponentDef.SheetMetalStyles.Item("20/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811196 AISI 304 sp. 3 SB + PVC", iProperties.Material = "811501 AISI 430 sp. 3 BA"
		oSheetMetalComponentDef.SheetMetalStyles.Item("30/10 In aria - 304/430").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("30/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811813 ALLUMINATA sp. 0.8"
		oSheetMetalComponentDef.SheetMetalStyles.Item("8/10 In aria - FE/ZN/ALLUMINATA").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811817 ALLUMINATA sp. 1"
		oSheetMetalComponentDef.SheetMetalStyles.Item("10/10 In aria - FE/ZN/ALLUMINATA").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811819 ALLUMINATA sp. 1.5"
		oSheetMetalComponentDef.SheetMetalStyles.Item("15/10 In aria - FE/ZN/ALLUMINATA").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811823 ALLUMINATA sp. 2", iProperties.Material = "811931 Fe sp. 2", iProperties.Material = "811939 FE-ZINCATO sp. 2"
		oSheetMetalComponentDef.SheetMetalStyles.Item("20/10 In aria - FE/ZN/ALLUMINATA").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
Case iProperties.Material = "811937 Fe sp. 3", iProperties.Material = "811941 FE-ZINCATO sp. 3"
		oSheetMetalComponentDef.SheetMetalStyles.Item("30/10 In aria - FE/ZN/ALLUMINATA").Activate
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("30/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
End Select
eND iF

 

 

This is the old one that work like a charm:

Dim oDoc As Document
		oDoc = ThisDoc.Document
Dim oSheetMetalComponentDef As Inventor.SheetMetalComponentDefinition
Dim okUnfoldMethod As Inventor.UnfoldMethod
oSheetMetalComponentDef = oDoc.ComponentDefinition

If iProperties.Material = "801171 AISI 304 sp.1 2B"
		SheetMetal.SetActiveStyle(“10/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "801181 AISI 304 sp. 1.2 2B"
		SheetMetal.SetActiveStyle(“12/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("12/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "801211 AISI 304 sp. 2 2B"
		SheetMetal.SetActiveStyle(“20/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811151 AISI 304 sp. 0.8 SB + PVC"
		SheetMetal.SetActiveStyle(“8/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811175 AISI 304 sp. 1 SB + PVC"
		SheetMetal.SetActiveStyle(“10/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811181 AISI 304 sp. 1.2 SB + PVC"
		SheetMetal.SetActiveStyle(“12/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("12/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811191 AISI 304 sp. 1.5 SB + PVC"
		SheetMetal.SetActiveStyle(“15/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811194 AISI 304 sp. 2 SB + PVC"
		SheetMetal.SetActiveStyle(“20/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811196 AISI 304 sp. 3 SB + PVC"
		SheetMetal.SetActiveStyle(“30/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("30/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811501 AISI 430 sp. 3 BA"
		SheetMetal.SetActiveStyle(“30/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("30/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811525 AISI 430 sp. 0.8 BA"
		SheetMetal.SetActiveStyle(“8/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811531 AISI 430 sp. 0.8 SB + PVC"
		SheetMetal.SetActiveStyle(“8/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811535 AISI 430 sp. 0.8 SB + PVC"
		SheetMetal.SetActiveStyle(“8/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("18/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811541 AISI 430 sp. 1 SB + PVC"
		SheetMetal.SetActiveStyle(“10/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811547 AISI 430 sp. 1 BA"
		SheetMetal.SetActiveStyle(“10/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811505 AISI 430 sp. 1.5 2B"
		SheetMetal.SetActiveStyle(“15/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811585 AISI 430 sp. 1.5 BA + PVC"
		SheetMetal.SetActiveStyle(“15/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811587 AISI 430 sp. 2 BA"
		SheetMetal.SetActiveStyle(“20/10 In aria - 304/430”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811813 ALLUMINATA sp. 0.8"
		SheetMetal.SetActiveStyle(“8/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("8/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811817 ALLUMINATA sp. 1"
		SheetMetal.SetActiveStyle(“10/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("10/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811819 ALLUMINATA sp. 1.5"
		SheetMetal.SetActiveStyle(“15/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("15/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811823 ALLUMINATA sp. 2"
		SheetMetal.SetActiveStyle(“20/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811931 Fe sp. 2"
		SheetMetal.SetActiveStyle(“20/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811937 Fe sp. 3"
		SheetMetal.SetActiveStyle(“30/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("12/10 In aria - 304/430")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811939 FE-ZINCATO sp. 2"
		SheetMetal.SetActiveStyle(“20/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("20/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
	Else If iProperties.Material = "811941 FE-ZINCATO sp. 3"
		SheetMetal.SetActiveStyle(“30/10 In aria - FE/ZN/ALLUMINATA”)
		okUnfoldMethod = oSheetMetalComponentDef.UnfoldMethods.Item("30/10 In aria - FE/ZN/ALLUMINATA")
		oSheetMetalComponentDef.UnfoldMethod = okUnfoldMethod
		
End If
 

 

In the old one, i haven't declare SheetMetal.SetActiveStyle, but it work.

Danilo "DannyGi" G.
Mechanical design engineer and product developer