iLogic - Selection of material-libary

iLogic - Selection of material-libary

uw
Advocate Advocate
2,740 Views
4 Replies
Message 1 of 5

iLogic - Selection of material-libary

uw
Advocate
Advocate

Hello!

 

I try to create an iLogic-rule (or rather a form) to select materials for Inventor(2019)-parts.

The selection of the material in the active material-libary is working fine - with a mulivalue-textparameter ("iPropMaterial") and following iLogic-Code:
-------------------------------------------
  MultiValue.List("iPropMaterial") = iProperties.Materials
  iProperties.Material=iPropMaterial
-------------------------------------------

Then I can choose the material by selecting it in a  iLogic form with a multivalue list.

No problem so far...

But I have many material-libaries in my project, and - if possible - I want to choose the libary first (on the same form) and then the material itself...

In other words: How can I select material-libaries in iLogic!

I am looking forward to your reply and your help!

 

Kind regards

Reinhard

0 Likes
Accepted solutions (1)
2,741 Views
4 Replies
Replies (4)
Message 2 of 5

clutsa
Collaborator
Collaborator

This appears to be working for me. Material_Lib and Material_Desc are custom Properties.

Dim app As Inventor.Application = ThisApplication
Dim proj As DesignProject = app.DesignProjectManager.ActiveDesignProject
Dim MyLibList As New ArrayList
For Each myLib In proj.MaterialLibraries
	MyLibList.Add(myLib.Name)
Next
MultiValue.List("Material_Lib") = MyLibList
'MessageBox.Show(MyLibList.IndexOf(Material_Lib)+1, "Title")
Dim LibIndex As Long
For Each appLib In app.AssetLibraries
	LibIndex = LibIndex + 1
	If Replace(appLib.DisplayName, " ", "") = Material_Lib Then Exit For
Next
app.ActiveMaterialLibrary = app.AssetLibraries.Item(LibIndex)


MultiValue.List("Material_Desc") = iProperties.Materials
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 5

uw
Advocate
Advocate

Hello.

 

Thank you for your reply, but my problem is not really solved yet...

I created a multi-value text-parameter "Material_Lib"

UW_01.png

 

 

 

 

 

 

 

 

and a rule with your code (just the part for the choosing of the material-libary):

UW_01.png


















And then I created a form to choose the "Material_Lib":UW_01.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And although I have 3 material-libaries in my project (with "favorits" there are 4) I can not select them:

UW_01.png

 

 

 

 

 

 

 

 

 

 

 

The only libary in the list is the "InventorMaterialLibary", but in my project the language is german, and the Name should be "Inventor-Materialbibliothek"...

 

I hope somebody can help me!

 

Regards

 Reinhard

0 Likes
Message 4 of 5

clutsa
Collaborator
Collaborator
Accepted solution

Try this...

Dim app As Inventor.Application = ThisApplication
Dim MyLibList As New ArrayList
For Each myLib In app.AssetLibraries
	If myLib.MaterialAssets.Count > 0 Then MyLibList.Add(myLib.DisplayName)
Next
MultiValue.List("Material_Lib") = MyLibList
'MessageBox.Show(MyLibList.IndexOf(Material_Lib)+1, "Title")

Dim LibIndex As Long
For Each appLib In app.AssetLibraries
	LibIndex = LibIndex + 1
	If appLib.DisplayName = Material_Lib Then Exit For
Next
app.ActiveMaterialLibrary = app.AssetLibraries.Item(LibIndex)
MultiValue.List("Material_Desc") = iProperties.Materials

it only grabs LibraryAssets that have Material Assets... for me Favorites is blank so it doesn't show up.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 5 of 5

uw
Advocate
Advocate

Hello!

 

Thank you very, very much!

That was exactly the code I was searching for!

It works perfectly!

 

Regards

 Reinhard