Hi!
Sorry: it's a very bad time for me. AU Vegas is behind the corner, I shall fly tomorrow morning and I still didn't pack my suitcase (and here it's 01:00!!).
Please keep in mind the following:
- it's absolutely impossible for me now to dig down into your specific issue (in 2 weeks I will gladly do it)
- I am absolutely ignorant in iLogic (I never needed, I never used it)
- I implemented the code from VGonsalves first in VBA and then in VBnet, which definitely works because it has updated more or less 220.000 ipt files with it
- I have only done it for IPTs because in my specific case it's 99% of the story (but could be equally done in IAMs)
- I have used this code in a batch processor that does a huge number of updating, cleaning, making nice on multiple inventor files... so the "AlignMaterials" is only a small part of the whole project (you can see an image of the batch processor here)
my inventor batch processor
So assuming that the code (VB.Net):
oPartDoc.ComponentDefinition.Material.UpdateFromGlobal()
works fine, I am giving you now the small additional detail that I had to figure out myself to make the batch processor work fine.
As you probably understood this program controls inventor and makes it do a number of actions. One of such actions is to read one specific custom iProperty (one string) seek the active material library for a material that is named exactly as the custom iProperty and then:
A) if a material asset with the same name is present in the file update it from material library
B) if no material asset with the same name is present in the file, seek the material library, copy it locally and assign it to the part
Case A) is under examination here, and I can grant that the code from VGonsalves works.
Since this program is designed to process thousands of files, inventor is restarted every random number of files (in the image 467) in order to clear cache and similar stuff. I have soon realized that, after restarting inventor, the seeking for assets in the material library was ranomly failing, even if everything was setup correctly.
I figured out that the first time one part is opened after a clean start, to some strange reason the material library CAN be not loaded. I could fix the problem decreasing the counter by 1 when this condition is met, and processing the file again: then everything got working perfectly, and I could go through 220.000 files within one weekend (with 10 workstations).
Maybe something similar is causing you the issue as well?
If I totally misunderstood your question, please bear till Nov 25: then I'll be back and I will be able to support you directly on VBA level.
Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH