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.?
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.
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.
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)
So, I ended up by adapting the .ipj via XML-editing.... 🙂
Hopefully, Autodesk keeps the ipj-format in the future. :))
BR,
Daniel
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