Add Iproperties from spreadsheet to parts

Add Iproperties from spreadsheet to parts

mc_inventor
Participant Participant
217 Views
1 Reply
Message 1 of 2

Add Iproperties from spreadsheet to parts

mc_inventor
Participant
Participant

Hi all,

 

Short version:

I need to import Iproperties from excel into ipt files.

 

I have a huge assembly full of parts that I want to change the iProperties of according to information I have on a spreadsheet. (e.g. Part1 should have a property1 value of "examplestring" and a property2 value of True).

 

The simplest method that I came to mind is importing these properties from a CSV file (because I have the data in excel).

After the changes, I would like to export another CSV with details about the operations that were done or omitted (e.g. a column with part name, old status of iprop(existed or not), old value of iprop, new value of iprop ). This is to have it in writing which iprops were successfully changed.

 

Alternatively, I could use a global rule 

 

I've written some pseudo-code:

 

read data from csv, import as 2D array
				
open all relevant docs				
for each doc				
	for each row in 2D array			
		if array(row,1) is the same as doc name	
                	set1,set2,val1a,val1b,val2a,val2b = false
			if iproperty array(1,2) doesnt exist	
				set iprop property1
				set1=true
			if iproperty array(1,3) doesn't exist	
				set iprop property2
				set2=true
			if value array(row,2) is not equal to property1.value
				val1a=property1.value
				val1b=array(row,2)
                                change property1.value
			if value array(row,3) is not equal to property1.value
				val2a=property2.value
				val2b=array(row,3)
                                change property2.value
			export to csv:set1,set2,val1a,val1b,val2a,val2b
                        

 Would you recon this to be an efficient way of tackling this, and would this code work the way I would like it to?

 

 

0 Likes
218 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

A combination of goexcel and or the excel object and a loop through the assembly referenced documents should be all you need for populating existing iproperties. Write it as an external rule. Probably best to write the property set existance, adding and value setting as functions. If your adding iproperties and doing checks that can get more complex. Are all the checks required? Is this an addin your looking to write or is it a simple general purpose tool? How much expierience have you with the API? 

Some helpful links:

Property sets access to iproperties

All Referenced Documents

Excel Access

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes