Compare MaterialAsset in Library against active one in Document

Compare MaterialAsset in Library against active one in Document

PolemEngineering
Advocate Advocate
379 Views
4 Replies
Message 1 of 5

Compare MaterialAsset in Library against active one in Document

PolemEngineering
Advocate
Advocate

How can I emulate the Update functionality for Styles and Standards in the Parts Environment in iLogic? In the Drawing Environment this was relatively easy. Purging in the Parts Enironment was also easy.

 

Why do I want this?

We have been using Inventor for almost 20 years. Over time, in addition to major changes in the Application itself, various style and template changes have also been implemented within our organization.

 

We are now in a transition from drawing-based to model-based working. By means of an iLogic rule triggered by the BeforeSave event, I now check whether each document meets certain requirements. If necessary, I will make changes or notify the user. These checks mainly concern names and settings for parameters and custom iProperties (necessary for the synchronization of data via Items to ERP).

 

The focus here is to only change as necessary and not simply overwrite with the same thing. So don't make it dirty unnecessarily.

 

As long as the execution time remains within limits, I will try to update some style things here and there (if applicable).

 

I was wondering if it is possible to compare material assets with each other. And thus possibly replace the active material in one document with that from a library.

René van der Starre

0 Likes
380 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @PolemEngineering.  That is a tough one.  I do not know of any built-in way to compare the two for changes/differences.  I am not sure how familiar you are with the Asset API object, or the derived MaterialAsset sub type, but they have a lot of AssetValue objects within them.  And AssetValue is just a base Type for a bunch of more accurate sub Types that are derived from the AssetValue Type, for dealing with different types of data.  Some of the more specific AssetValue objects can even have multiple values.  It would take a large, and complex code to iterate down through all of those, check their type, create a variable of that more specific type, and set its value, then inspect each of them against the same AssetValue of the 'other' Asset/MaterialAsset object.  There is an API Sample VBA macro code you can look at to get a better idea of what to expect when going that route. 

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=DumpDocumentMaterials_Sample 

I have done a deep dive into them before on a couple occasions, but it was time consuming each time.

I have attached one of my iLogic 'inspection' type codes as a text file, which is somewhat similar to that VBA macro, but updated.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

PolemEngineering
Advocate
Advocate

I was already looking into Assets because I think I understood that the Materials Object is or is becoming more or less obsolete.
Otherwise the boolean .UpToDate and the function .UpdateFromGlobal would have been a nice solution.

 

Also found the topic UpdateFromGlobal() for Materials 

René van der Starre

0 Likes
Message 4 of 5

Maxim-CADman77
Advisor
Advisor

Dear @MjDeck 
Is

that true there is no easy way to check if local material asset differs from that in library?

MaximCADman77_0-1725860415527.png

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 5 of 5

MjDeck
Autodesk
Autodesk

@Maxim-CADman77 , I haven't found a way to determine if one asset differs from another one. However, the Asset.CopyTo method (with ReplaceExisting := True) will not dirty the document if the source and destination assets are already the same.
I think the rule that @WCrihfield posted in message 21 on the other thread might be good for this purpose. I'm double-checking now.

I also want to note that there might be a good reason to override a material property in a particular model. And there might also be a good reason why a material property stored in a library might change over time. Just something to think about before you do automatic updates.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes