Inventor General Discussion

Inventor General Discussion

Reply
Distinguished Contributor
DRoam
Posts: 134
Registered: ‎01-03-2013
Message 1 of 5 (3,391 Views)
Accepted Solution

Use iLogic to change custom iProperty in several components at once

3391 Views, 4 Replies
03-25-2013 09:06 AM

I've been using iLogic more and more, and it's been amazingly helpful, but I'm at a loss on this problem. I'm creating a template assembly that will be used for multiple jobs. Therefore, the job number will be changing. I want a custom iProperty in ALL parts and sub-assemblies (cleverly call it "Job #" maybe) that I can include an a separate property called "Drawing #" which whose value will be [some text]-<Job #>-[some more text]. I want to be able to update all the "some text" parts manually for each component, but I want the Job # to update automatically. I need this property because I have a column in all my Parts Lists called "Drawing #" which tells the drawing number for any given part or assembly.

 

Ultimately what I want to do is open a text or Excel file, enter the job number, open my Inventor drawing, and have every Drawing # entry in every parts list magically update to the correct job number.

 

I've managed to use iLogic to do just that with a single .ipt/.iam file. But I have dozens upon dozens of components in the main assembly. I'd like to run some rule or hit some button or do something that will cause the Job # property to update for ALL sub-assemblies and parts, so that all my parts lists reflect the change. Any ideas would be appreciated. Thanks!

A while back we thought of doing the same thing.  But before we put any time into developing an iLogic rule to do this, we investigated the Design Assistant.  It turns out that this works well enough that we haven't bothered to work out the iLogic rule.

 

Have you ever used the design assistant?  If not, I can give you some instructions on how to do what you want with it.

 


-cwhetten

*Expert Elite*
jtylerbc
Posts: 897
Registered: ‎09-01-2010
Message 2 of 5 (3,380 Views)

Re: Use iLogic to change custom iProperty in several components at once

03-25-2013 09:21 AM in reply to: DRoam

My misfortune may be your gain.  Not too long ago I was trying to create a rule that filled in a property for any part that had a view in a drawing.  It failed miserably because it filled in the parameter in every part if there was a view of the assembly - it seems that my bug may be your feature.

 

This rule goes through all documents referenced by the drawing, then checks to see if the documents are parts.  If it is a part, it fills in a custom property called "SK", and amends it to the existing part Description property.  For example, if it references a part that was previously described as:

 

 PLATE-5" X 5"

 

it will change it to:

 

PLATE-5" X 5" (SK)

 

This rule (when run from the drawing) should look at all documents referenced by that drawing and fill out the property.  If your drawing contains a view of the main assembly, you'll get the property filled out in every subassembly and part it contains.  You'll need to change my property name "SK" to your desired property, and remove my "part check" code, as well as my code that amends the "SK" property to the existing description field.

 

 

Dim openDoc As Inventor.Document
Dim docFile As Inventor.Document
Dim DrawingDoc As DrawingDocument
Dim FNamePos As Long
Dim docFName As String
Dim iDesc as String

DrawingDoc = openDoc
openDoc = ThisApplication.ActiveDocument
iDesc = iProperties.Value("Project", "Description")

For Each docFile In openDoc.AllReferencedDocuments

'	Check if referenced document is a Part file.  If it is, fill in the SK field.
	If docFile.DocumentType = kPartDocumentObject Then
		'If Not Mid(iDesc, Len(iDesc) - 4, 4) = "<SK>" Then 
		'	iDesc = iDesc + "<SK>"
		'End If
		
		FNamePos = InStrRev(docFile.FullFileName, "\", - 1)
		docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos)
		iProperties.Value(docFName, "Custom", "SK") = "(SK)"
	
	End If
Next

iLogicVb.UpdateWhenDone = True

 

The key part of this code for you is the openDoc.AllReferencedDocuments.  This is what will find all of the components you are looking for, and allow you to fill the property in for them.

 

John Tyler
Inventor 2015
Windows 7 64 Bit
*Expert Elite*
cwhetten
Posts: 1,090
Registered: ‎09-03-2008
Message 3 of 5 (3,384 Views)

Re: Use iLogic to change custom iProperty in several components at once

03-25-2013 09:25 AM in reply to: DRoam

A while back we thought of doing the same thing.  But before we put any time into developing an iLogic rule to do this, we investigated the Design Assistant.  It turns out that this works well enough that we haven't bothered to work out the iLogic rule.

 

Have you ever used the design assistant?  If not, I can give you some instructions on how to do what you want with it.

 


-cwhetten

Distinguished Contributor
DRoam
Posts: 134
Registered: ‎01-03-2013
Message 4 of 5 (3,361 Views)

Re: Use iLogic to change custom iProperty in several components at once

03-25-2013 10:46 AM in reply to: DRoam

Those are both greath suggestions, thanks to both of you! cwhetten, I didn't know you could do something like that with the Design Assistant, but I looked into it and that may work! Do you mean using the Copy Design Properties tool? If so, it does look like that should do the trick! Not quite as simple as changing and Excel value but not near as complicated as creating an iLogic rule in dozens of files, either.

 

jtylerbc, your suggestion sounds like it might be more simple if I can experiment with it and taylor it to what I need, so I'll probably look into that too when I have time.

 

Great suggestions, thanks again!

*Expert Elite*
cwhetten
Posts: 1,090
Registered: ‎09-03-2008
Message 5 of 5 (3,352 Views)

Re: Use iLogic to change custom iProperty in several components at once

03-25-2013 11:41 AM in reply to: DRoam

You could use the Copy Design Properties tool if you want to copy one or more properties from one file to a list of other files, but you can also just modify the value of a property in multiple files at once.

 

To bulk-edit a property in multiple drawings at once, you have several options.  If all of your files are located in the same folder, you can go to File > Open Folder.  This will add all files in that folder to the list.  We use this to modify some title block properties on a bunch of drawings all at once, and all of our drawings are in a single folder, so we just open that folder and take care of it all at once.  If your folder structure is complex, then you will have to modify them one folder at a time and the design assistant might not be very convenient.

 

That said, however, the Copy Design Properties tool has an option to go through subfolders, so as long as you can identify one top-level folder that contains everything that you wish to modify, then you could use this tool.  In order to do so, you would need to set up one file first, then copy that file's properties to the rest of them.

 

Hopefully this makes sense.

 

-cwhetten

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.