Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Material Library

5 REPLIES 5
Reply
Message 1 of 6
KentKeller
709 Views, 5 Replies

Select Material Library

I am working in 2013 right now. My project loads two material libraries, and I am finding that if the Autodesk Material Library is selected in the dropdown, and I try to set the material to something in my Custom library, it fails.  If I first select my custom library to make it the active one, then my code works fine. 

 

So my question is, how do I set my custom library to be the active one, or better yet, so that it will look through both library's and pick the material from the library that has it.? 

Kent Keller
KWiKMcad

5 REPLIES 5
Message 2 of 6

The 2013 API is not supporting to select the material library like autodesk Materilal library or Inventor material Library. I used to make the library active by selecting manualy to all the libraries before I run my addin. But in Inventor 2014 API is supporting to change or select the active library.

Message 3 of 6

That's correct 2014 is coming with API access to the new material library. The property Application.ActiveMaterialLibrary allows you to set the active library.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 4 of 6

Hi, could you please give a hint, how this should work?

I tried to set it by

 

iApp.ActiveMateriallibrary =  lib

where lib is a ProjectAssetlibrary. I got an exception, that Assetlibrary and ProjectAssetlibrary has no "="-Operator defined.

Tried to get the "lib" via iApp.Assetlibraries.Item which did not work, since it's a ProjectAssetlibrary...

Ok, then I tried to add it to the iApp.AssetLibraries.add (lib.LibraryFileName). Got an Exception "Invalid Argument"...

I also tried to

 

iApp.ActiveMaterialLibrary = iApp.AssetLibraries.Item (2)

 

This gave me the same undefined "="-Operator for Assetlibrary and Assetlibrary...

I did not find a "Set" method for iApp.ActiveMaterialLibrary (normally it wouldn't be needed, since it's Property...)

 

If I try to Activate the Projectassetlibrary directly by the Activate Method, and check the Project settings, both (the original and the new one) are marked as active, which, of course is invalid state....

 

Thanks in Advance,

Daniel

 

PS: I use Inventor 2015 Pro for debug, although I have the inventor.interop v.18.0.0.0 referenced in my project for compatibility reason (my customer has 2014)

 

Message 5 of 6

So, I ended up by adapting the .ipj via XML-editing.... 🙂

Hopefully, Autodesk keeps the ipj-format in the future. :))

BR,

Daniel

Message 6 of 6

I wrote an ExtensionMethod to the ProjectAssetLibraries-Object, where I pass the Name of the desired Library as argument. 

I call it by 

 

'iApp is the currentapplication
'"MyName..." is the Name of the customlibrary, assumed its already added to the ipj

iApp.DesignProjectManager.ActiveDesignProject.MaterialLibraries.ActivateByName ("myNameMat")
iApp.DesignProjectManager.ActiveDesignProject.AppearanceLibraries.ActivateByName ("myNameApp")

BR,

Daniel

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report