Inventor iLogic Script to Create New Custom iProperties from New Array List

Inventor iLogic Script to Create New Custom iProperties from New Array List

James_OBrien2
Contributor Contributor
2,068 Views
1 Reply
Message 1 of 2

Inventor iLogic Script to Create New Custom iProperties from New Array List

James_OBrien2
Contributor
Contributor

Hello, I was wondering if anyone can assist with the relevant coding required to generate a new Custom iProperty. I have a number of parts with all sorts of different iproperties and I want to do a clean up to only include for the ones in the MyArrayList. Therefore the purpose of the script is to perform a check of a existing custom iProperty set within the part and first of all add in the Custom iProperties that are missing then do another check then delete the unwanted custom iProperties that are not on the list. I have attached my current script and the problem area is on Line 102 as I um unable to create the missing iProperties from the MyArrayList. If anyone could assist that would be most appreciated. Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 43415 StartFragment: 314 EndFragment: 43383 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet 'define list of custom properties to delete Dim MyArrayList As New ArrayList MyArrayList.add("Plant Item No.") MyArrayList.add("Sub Assembly No.") MyArrayList.add("Part No.") MyArrayList.add("Fabrication Item") MyArrayList.add("Security Classification of Model") MyArrayList.add("Configuration Management Category") MyArrayList.add("Master Model Location") MyArrayList.add("Revision and Version of Model") MyArrayList.add("Status of Issue") MyArrayList.add("Purpose of Model Issue") MyArrayList.add("Design Organisation") MyArrayList.add("Modelled By") MyArrayList.add("Level of Check") MyArrayList.add("Checked By") MyArrayList.add("Date of Check") MyArrayList.add("Approved By") MyArrayList.add("Date of Approval") MyArrayList.add("Accepted By") MyArrayList.add("Date of Acceptance") MyArrayList.add("Designers Project Number") MyArrayList.add("Designers Work Package Number") MyArrayList.add("Project Title") MyArrayList.add("Work Pack Title") MyArrayList.add("Equipment Title") MyArrayList.add("Site/Location") MyArrayList.add("Plant Title") MyArrayList.add("Building Number") MyArrayList.add("System No.") MyArrayList.add("Plant Area") MyArrayList.add("Department") MyArrayList.add("File Code") MyArrayList.add("Manufactured/Proprietary") MyArrayList.add("Design Quality Plan Reference No.") MyArrayList.add("Quality Grade of Item") MyArrayList.add("Item Description") MyArrayList.add("Item Designation") MyArrayList.add("Item Size Designation") MyArrayList.add("Material Designation") MyArrayList.add("Heat Treatment Designation") MyArrayList.add("Weld Standard Designation") MyArrayList.add("Non Destructive Testing Designation") MyArrayList.add("% Coverage of Non-Destructive Testing") MyArrayList.add("Protective Coating Designation") MyArrayList.add("Paint Designation") MyArrayList.add("Paint Colour Designation") MyArrayList.add("Identification Marking Designation") MyArrayList.add("Information Marking Designation") MyArrayList.add("FAT Testing Designation") MyArrayList.add("Manufacturing Specification No.") MyArrayList.add("Testing Specification No.") MyArrayList.add("Supplier Product Code") MyArrayList.add("Supplier") MyArrayList.add("Supplier Contact Details") MyArrayList.add("Extent of Scope") MyArrayList.add("Manufacturers Quality Plan No.") MyArrayList.add("Manufacturers Drawing No.") MyArrayList.add("Manufacturers Purchase Order Number") MyArrayList.add("Manufacturers Quote No.") MyArrayList.add("Is Certification of Goods Required?") MyArrayList.add("Type of Certification Required") MyArrayList.add("Order Date") MyArrayList.add("Date Due In") MyArrayList.add("Date Goods Received") MyArrayList.add("Recipient of Goods") MyArrayList.add("Goods Inward Inspection Complete") MyArrayList.add("Goods Storage Location") MyArrayList.add("Index Number") MyArrayList.add("Cast No.") MyArrayList.add("Page No.") MyArrayList.add("Manufacturing Location") MyArrayList.add("Manufacturing Status") MyArrayList.add("FAT Testing Status") MyArrayList.add("Technical Query Reference") MyArrayList.add("Production Permit Reference") MyArrayList.add("Concession Reference") MyArrayList.add("Verify Goods Inwards Inspection") MyArrayList.add("Verify Material Certificates") MyArrayList.add("Verify Consumable Certificates") MyArrayList.add("Verify Weld Procedure Approval") MyArrayList.add("Verify Welder Qualification Approval") MyArrayList.add("Verify NDT Procedure Approval") MyArrayList.add("Verify NDT Operator Approval") MyArrayList.add("Verify Paint Procedure Approval") MyArrayList.add("Verify In Process Inspection") MyArrayList.add("Conduct Visual Inspection") MyArrayList.add("Conduct Dimensional Inspection") MyArrayList.add("Verify NDT Inspection Completion") MyArrayList.add("Verify FAT Test Completion") MyArrayList.add("Sign off and Dispatch Release Note") 'define custom property collection oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") 'look at each property in the collection For Each oCustProp In oCustomPropertySet 'check property name against the list you don't want to delete If MyArrayList.Contains(oCustProp.Name) Then 'Skip Else 'Create a new iProperty if the existing custom iProperties doesn't contain the parameter in MyArrayList iProperties.Value(doc, "Custom", MyArrayList.Name) End If If MyArrayList.Contains(oCustProp.Name)Then 'skip it Else 'Delete the custom iProperty oCustProp.Delete End If Next

 

kelly.young has edited your subject line for clarity: iLogic Sript to Create New Custom iProperties from New Array List

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi James.OBrien2,

 

Welcome to the forums.

 

Note that for programming questions of this type there is a dedicated Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

 

Note to that in the window that you type is an Insert Code button that will allow you to paste in code in a manner that formats it correctly.

 

Code Window.PNG

 

With all of that in mind for the future, see this example ilogic rule that compares the existing iProperty collection to the arraylist, and adds those not found to exist, and deletes those not listed.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDoc as Document
oDoc = ThisDoc.Document
'define list of custom properties to delete 
Dim MyArrayList As New ArrayList 
MyArrayList.add("Hello") 
MyArrayList.add("World") 
MyArrayList.add("Autodesk") 
MyArrayList.add("Inventor") 

'define custom property collection 
oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties") 


'[ 'create iprops missing from list
For Each oItem in MyArrayList
	oFlag = False 'set flag to default value
	'look at each property in the collection 
	For Each oCustProp In oCustomPropertySet
		'check property name against the list item
		If oItem = oCustProp.Name Then 
			oFlag = True 'trip the flag
		End If 
	Next
	
	If oFlag = False Then
		'Create new iProperty
		iProperties.Value(oDoc, "Custom", oItem ) = ""
	End If
Next
'] 

'[ remove old iProps not in list
For Each oCustProp In oCustomPropertySet
	oFlag = False 'set flag to default value
	For Each oItem in MyArrayList
		'check property name against the list item
		If oCustProp.Name = oItem Then 
			oFlag = True 'trip the flag
		End If 
	Next
	
	If oFlag = False Then
		'delete property
		oCustProp.Delete
	End If
Next
']

 

EESignature