Linking part's material to a library? I would like to modify the library material and have the parts and drwings automatically update whit the new name of the material

Linking part's material to a library? I would like to modify the library material and have the parts and drwings automatically update whit the new name of the material

gperri1
Contributor Contributor
396 Views
6 Replies
Message 1 of 7

Linking part's material to a library? I would like to modify the library material and have the parts and drwings automatically update whit the new name of the material

gperri1
Contributor
Contributor

As I described in this post:

https://forums.autodesk.com/t5/inventor-forum/can-i-link-part-s-material-to-a-library-when-i-modify-...

 

Iwould like to have parts and drawings auto-updated when I change the material in my material library.

Any ideas on how to code this?

 

Thank you

0 Likes
397 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @gperri1.  As mentioned in the other post, instructing the Inventor application to respond to very custom events in custom ways like that would almost definitely need to be done with something like an Inventor.ApplicationAddin.  To create an add-in like that would require a lot of coding knowledge, a better coding platform like Visual Studio, and a lot of knowledge about how all that stuff works within the Inventor API system.  I am not even sure it is possible, even with an add-in.  In most cases, even if a 'model' has changed, the existing assemblies and/or drawings that reference that 'model' will not be updated until the next time you actually open those assemblies and/or drawings.  And if you have hundreds or thousands of files to sift through, in an attempt to update everything every time, that could freeze or crash Inventor.  This is simply not the type of behavior that can be enabled with a simple iLogic rule.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

Frederick_Law
Mentor
Mentor

Library is not supposed to change often.

Develop it before you design everything.

I'm at a new job and developing everything.

Template, style, material.

So I do have files with different "versions" library that need to get update.

 

Easiest is update when you open the file.

iLogic or addin user run on demand.

Then add it to file open trigger.

 

Another is update all files inside folder.

Test code with a small batch of files to make sure there is no error.

Run it overnight or on weekend.

 

Then it can be a custom Task Scheduler job.  Probably not gonna go that far.

 

Right now I have iLogic to update Drawing Resource.

Part files are manually update when edit.

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Another way to look at this is...the data within the material library is not 'linked to' or 'referencing' or 'referenced by' any model files, therefore there is no way to tell what model files may be currently using that material.  Within part files is an area for local copies of materials and appearances.  In order for a part to 'use' a material or appearance, that material or appearance must first exist within one of these two 'local' (stored within the document) collections.  If you open a part, and that part's 'active' material's name is the same as a material that exists within an external material library, you can choose to update the local copy of the material to be like the one in the library.  Or you can choose to update the library material to be like the local copy.  You can also purge any unused local copies of materials and appearances.  So, the update (one way or the other) is initiated from the part, not the library, because the library has no idea what all model files may be out there containing local copies of the Assets with the same names as found within that library.

 

As mentioned by @Frederick_Law, you can either do this update using the user interface tools found on the Manage tab, Styles and Standards panel, or you can run some code on that individual model file that will attempt to check the local assets within it, then check to see if any of them have the same name (and are the same type) as assets within a specified AssetLibrary.  If a match is found, the code can then attempt to copy the library version down to the model file, and optionally replace the existing local Asset within the model file.  There are several codes for that type of task, but I have attached an example iLogic code that I had on hand for you to try out.  It is attached as a text file.  That example can be ran while the model document is open, and the 'active' document (showing on your screen), or you can run it remotely with the iLogicVb.RunExternalRule(sRuleName, oArgs) type calls to run this rule from another rule.  And it is set-up to optionally 'receive' the Document object to focus on, if you choose to use it that way.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

WCrihfield
Mentor
Mentor

If you just changed some stuff in your material library, and want to update your files to match the changes, one process touched upon earlier would be to run an iLogic rule that will attempt to 'process' an entire directory of files at a time, and optionally step down into sub directories.  This process would need to actually open every model type file (primarily parts, but also assemblies, if needed) in Inventor, but it does not need to be 'visibly' opened.  Then that Document can be processed by some code similar to the code I provided above.  But if there are a lot of files, you will most likely not want to run it on a ton of files while you are trying to use Inventor for other things, because it will likely slow Inventor down a lot while it is running.  I do not recall there being any actual 'Event' that we can listen for that would tell us if a specific material library has been changed, so the rule/process may need to be started manually, when it is most convenient for you.  You can however, set a rule like this up to run on whatever part you open in the future by putting a rule like this into the Event Triggers dialog, on the 'Parts' tab, under the 'After Open Document' event.  But that might possibly get annoying or slow Inventor down in certain situations.  This is because parts can be opened indirectly, by opening either an assembly that contains a component referencing it, or by opening a drawing that references it.  Every time something like that happens, it will run that rule.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

gperri1
Contributor
Contributor

Thank you for the support!

I'll try something and have to study how to create an API, I'll update you!

 

*Just for curiosity: why to assign a material to a part, Inventor force you to save a local copy in the part and not simply link to the library?

I imagine that if I delete or lose a library, my material would lose the material assigned, but wouldn't be a good idea to be able to automatically link the file's material to a library? Maybe whit a flag "linked material or local copy of material"

 

Thank you

0 Likes
Message 7 of 7

Frederick_Law
Mentor
Mentor

When you share file with customer, they don't have your library.

They will not have material spec.

 

And same if you lost library (reinstall Inventor, Windows), all your material are lost.  You will not know what material was used.