Using material option in form.

Using material option in form.

Anonymous
Not applicable
3,733 Views
11 Replies
Message 1 of 12

Using material option in form.

Anonymous
Not applicable

Good day,

I am busy with fine tuning our templates for parts, assemblies and drawings created in Inventor.  One of the things on my list is to simplify (also read "enforce") the correct entry of specific information at part, assembly and drawing level.  So one of the main issues I have is that when one brings in contractors for limited term work, their understanding of our company processes are not quite where it should be to ensure a smooth flowing process from 3D modelling through to producing drawings.

 

So the idea is to use an event linked iLogic Form to ensure that they are reminded about very specific information / meta data / properties that needs to be entered during this time in the process.  I have been able to get just about everything to work, except to show the material selection in my Form.  It is not shown under the iProperties or parameters options when one creates the Form so I cannot just simply drag the option across.  I Googled the issue but the one possible solution I found also does not do the trick.  Basically I want to replicate the drop down selection to specify the material, but just in the Form environment.  Below is a screen capture of the Form as I have it currently (work in progress), the material listing should be where the Material heading is.

Screen capture of current FormScreen capture of current Form

 

Anyone that can assist with this please?

 

Regards

 

Kobus

0 Likes
Accepted solutions (2)
3,734 Views
11 Replies
Replies (11)
Message 2 of 12

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, I'll give you some examples in ilogic that maybe they could serve you.
If you only want to read your active material on your form you could use the following code.

 

Dim oDoc As PartDocument = ThisDoc.Document
MessageBox.Show(oDoc.ActiveMaterial.DisplayName)

If you want to change material, I think a good approach would be to previously select the library, and then select the material as in the following code

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oAL_List As New ArrayList
Dim lib_List As New ArrayList

For Each oAL As AssetLibrary In ThisApplication.AssetLibraries
	If InStr(oAL.DisplayName , "Material") <> 0 Then  
		oAL_List.Add(oAL.DisplayName)
	End If
Next

Dim oALSelect As String = InputListBox("Select Asset Library", oAL_List, oAL_List(0), "Change Part Material", "Available Selections")
If oALSelect Is Nothing Then Exit Sub
Dim oLib As AssetLibrary =ThisApplication.AssetLibraries(oALSelect)

For Each libAsset In oLib.MaterialAssets
	lib_List.Add(libAsset.DisplayName)
Next

Dim oLibAssetSel As String = InputListBox("Select Material", lib_List, lib_List(0), "Change Part Material", "Available Selections")
If oLibAssetSel Is Nothing Then Exit Sub

oDoc.ActiveMaterial = oLib.MaterialAssets.Item(oLibAssetSel)

iLogicVb.UpdateWhenDone = True

 I hope this helps with your form, regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 12

Pieter_vBiljon
Contributor
Contributor

Hi @Sergio.D.Suárez 

Thank you for this code. It did work for me, but I made a small change and predefined the Material library that needs to be selected. But one issue I found was that the material list that is displayed is not sorted whatsoever and materials is all over the place. Any ideas on how to solve it to be sorted alphabetically?

 

Message 4 of 12

JBerns
Advisor
Advisor
Accepted solution

@Pieter_vBiljon,

 

You likely have your answer by now, but for the benefit of others I offer this solution.

 

Use the Sort method  on the list object after the list of materials has been created.

 

For Each libAsset In oLib.MaterialAssets
	lib_List.Add(libAsset.DisplayName)
Next

lib_List.Sort

 

Hope this is helpful.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 5 of 12

Pieter_vBiljon
Contributor
Contributor
Thank you @Anonymous.
0 Likes
Message 6 of 12

JBerns
Advisor
Advisor

Welcome, @Pieter_vBiljon 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 7 of 12

GosponZ
Collaborator
Collaborator

Rule is working perfect but i can't see my custom Library. It is just this two. Some help please. Thanks

GosponZ_0-1628733383229.png

 

0 Likes
Message 8 of 12

JBerns
Advisor
Advisor

@GosponZ,

When in a part or assembly, what libraries are available from the Material menu?

2021-08-12_7-24-36.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Is your library available in the current project?

2021-08-12_7-29-39.png

 

Beyond those two factors, I am not sure why your custom library would not be listed.

Perhaps others may have an idea.

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 9 of 12

GosponZ
Collaborator
Collaborator

i do see my Library but not when running rule as i placed screen shot. Al material i 'm taking from My Library

0 Likes
Message 10 of 12

WCrihfield
Mentor
Mentor

Hi @GosponZ.  In the code that @Sergio.D.Suárez posted, he is filtering library names and only getting ones with "Material" in the name.  You may have to change that line of code to include any that don't contain that exact text in the name.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 12

JBerns
Advisor
Advisor

Thanks @WCrihfield , for pointing that out. I overlooked that.

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 12 of 12

GosponZ
Collaborator
Collaborator

Indeed that was so simple. Thank you

0 Likes