I am trying to add iproperties and parameters to a part through ilogic

I am trying to add iproperties and parameters to a part through ilogic

Anonymous
Not applicable
539 Views
1 Reply
Message 1 of 2

I am trying to add iproperties and parameters to a part through ilogic

Anonymous
Not applicable

This is part of the ilogic code below to add custom iproperties and user defined parameters from arraylists to a part and the missing ilogic is to add iproperties and parameters when document is an assembly (traverse and use recursive function to add them to everything in structure)..

 

The problem is when the rule is ran the hour glass doesn't stop and I have to close inventor down to stop the rule or the fact that inventor has stopped responding... What is my error or errors????

 

Code Below:

 

Version:1.0 StartHTML:00000145 EndHTML:00023623 StartFragment:00000294 EndFragment:00023591 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet

'Check if Active Document is not a Part/Assembly File
oDoc = ThisDoc.Document

If oDoc.DocumentType = kDrawingDocumentObject Then
MessageBox.Show("This Rule Can Only Be Run In Part and Assembly Files!")
Return
End If

' Check if Active Document is a Part File
If oDoc.DocumentType = kPartDocumentObject Then
	
'Define List of Custom Properties
Dim MyArrayList As New ArrayList

MyArrayList.Add("1A. NOUN")
MyArrayList.Add("1B. 1ST-MOD")
MyArrayList.Add("1C. 2ND-MOD")
MyArrayList.Add("1D. DESCR")
MyArrayList.Add("1E. MATERIAL")
MyArrayList.Add("1F. BEND NOTES")
MyArrayList.Add("1G. REVISION LETTER")
MyArrayList.Add("1H. DESIGN STATUS")
MyArrayList.Add("1H. PROVIDE CODE")
MyArrayList.Add("1H. UoM")
MyArrayList.Add("1I. PREP ID")


MyArrayList.Add("ID BEND")
MyArrayList.Add("ID EPOXY")
MyArrayList.Add("ID HEAT SHRINK")
MyArrayList.Add("ID INSERT")
MyArrayList.Add("ID MANU. NOTES")
MyArrayList.Add("ID PAINT")
MyArrayList.Add("ID RIVET NUT")
MyArrayList.Add("ID WELD")


MyArrayList.Add("2. STANDARD NAME ID")
MyArrayList.Add("2A. PART MAIN GROUP")
MyArrayList.Add("2B. PART CLASS ID")
MyArrayList.Add("2C. TECHNICAL CLASS ID (PART)")
MyArrayList.Add("2D. TECHNICAL CLASS ID (ASSY)")
MyArrayList.Add("2E. TECHNICAL CLASS ID (VNDR)")
MyArrayList.Add("2F. TECHNICAL CLASS ID")


MyArrayList.Add("3. MANUFACTURER NO")
MyArrayList.Add("3A. MANUFACTURER'S PART NO")

MyArrayList.Add("4. RAW MATERIAL")
MyArrayList.Add("4A. LENGTH")
MyArrayList.Add("4B. WIDTH")
MyArrayList.Add("4C. AREA OF PART")
MyArrayList.Add("4C. WEIGHT")

MyArrayList.Add("ENGINEERING DESIGN GROUP")

'Define List of Custom Parameters
Dim MyParamList As New ArrayList

MyParamList.Add("StdName")
MyParamList.Add("PartClass")
MyParamList.Add("PartMainGroup")
MyParamList.Add("TechClass")
MyParamList.Add("PCode")
MyParamList.Add("UoM")
MyParamList.Add("RawMaterial")
MyParamList.Add("BendNotes")
MyParamList.Add("PrepId")
MyParamList.Add("SheetMetalStyle")
MyParamList.Add("EngApprover")
MyParamList.Add("BEND")
MyParamList.Add("EPOXY")
MyParamList.Add("INSERT")
MyParamList.Add("MFRNOTE")
MyParamList.Add("PAINT")
MyParamList.Add("RIVNUT")
MyParamList.Add("HSINK")
MyParamList.Add("WELD")
MyParamList.Add("NOUN")
MyParamList.Add("F_MOD")
MyParamList.Add("S_MOD")
MyParamList.Add("ENABLE")


	'Define Custom Property Collection (ALL)
	oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
	Dim oCustProp As Inventor.Property
	
	Dim i As Integer 
	'Dim oString As Object
	
	'Look at Each Property in The Collection
	For Each oCustProp In oCustomPropertySet
		
			'Check Property Name Against the List 
			If MyArrayList.Contains(oCustProp.name) Then
			'Skip It
				
			Else
				'Delete Custom Properties
				oCustProp.Delete 
				
			End If
				
	Next
	
	'Look at Each Value in ArrayList

	For i = 0 To MyArrayList.Count - 1
		
			'Check List Against Properties
			For Each oCustProp In oCustomPropertySet
				If oCustProp.Name = MyArrayList.Item(i) Then	
			'Skip It
			
			
				Else
				'Add Custom iProperties From List
				oCustomPropertySet.Add("", MyArrayList.Item(i)) 
				
				End If	
			
			Next	
	Next 
	
				
	'Define User Parameter Collection (ALL) 
	
	oUserParamSet = oDoc.ComponentDefinition.Parameters.UserParameters 
	Dim oUserParam As UserParameter
	
	
	'Look at Each Parameter in the User Parameter Collection
	
		'Look at Each Value in ArrayList
	For i = 0 To MyParamList.Count - 1
		
			'Check List Against Properties
			For Each oUserParam In oUserParamSet
				If oUserParam.Name = MyParamList.Item(i) Then	
			'Skip It
			
				Else
				'Add Custom iProperties From List
				oUserParamSet.AddByValue(MyParamList.Item(i), "", UnitsTypeEnum.kTextUnits)
				
				End If	
			
			Next
	Next 
	
	
	'Set Boolean Value
	'Dim Boolean1 As Boolean
	'Boolean1 = False
	
	'Set Sheet Metal Style Variable
	SM = SheetMetal.GetActiveStyle()

	'Set Custom iProperties Values
	iProperties.Value("Custom", "ENGINEERING DESIGN GROUP") = "1510"
	
	
	'Set Custom Parameter Values
	MultiValue.SetList("ENABLE", True, False)
	MultiValue.SetList("BEND", "Y", "N")
	MultiValue.SetList("EPOXY", "Y", "N")
	MultiValue.SetList("INSERT", "Y", "N")
	MultiValue.SetList("MFRNOTE", "Y", "N")
	MultiValue.SetList("PAINT", "Y", "N")
	MultiValue.SetList("RIVNUT", "Y", "N")
	MultiValue.SetList("HSINK", "Y", "N")
	MultiValue.SetList("WELD", "Y", "N")
	MultiValue.SetList("UoM", "EA", "in", "in2")
	MultiValue.SetList("PartMainGroup", "PEP-MAKE", "PEP-BUY")
	MultiValue.SetList("PCode", "Make", "Buy")
	MultiValue.SetList("EngApprover", "ENGR", "DIR", "MGR", "ABE", "N/A")
	MultiValue.SetList("BendNotes", "NO BENDS", "BEND AS INDICATED", "BEND AS INDICATED, FORM 1 AS SHOWN AND 1 OPPOSITE", "ALL BENDS DOWN 90",
	"ALL BENDS DOWN 90, FORM 1 AS SHOWN AND 1 OPPOSITE", "BEND DOWN 90 EXCEPT WHERE NOTED OTHERWISE", "BEND DOWN 90 EXCEPT WHERE NOTED OTHERWISE, FORM 1 AS SHOWN AND 1 OPPOSITE",
	"ALL BENDS UP 90", "ALL BENDS UP 90, FORM 1 AS SHOWN AND 1 OPPOSITE", "BEND UP 90 EXCEPT WHERE NOTED OTHERWISE", "BEND UP 90 EXCEPT WHERE NOTED OTHERWISE, FORM 1 AS SHOWN AND 1 OPPOSITE")
	oUserParamSet.AddByValue("StdName", "PEP-ME", UnitsTypeEnum.kTextUnits)
	oUserParamSet.AddByValue("SheetMetalStyle", SM, UnitsTypeEnum.kTextUnits)
	
'Update File
RuleParametersOutput()
InventorVb.DocumentUpdate()

MessageBox.Show("All Properties have been Added to All Part(s)", "iLogic")

 

0 Likes
Accepted solutions (1)
540 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

I found the solution for anyone interested or experiencing similar issues..

 

Reference solution below by Curtis W.

 

https://forums.autodesk.com/t5/inventor-customization/inventor-ilogic-script-to-create-new-custom-ip...

0 Likes