Material Description as custom Iproperty

Material Description as custom Iproperty

beth.maddux
Participant Participant
1,172 Views
3 Replies
Message 1 of 4

Material Description as custom Iproperty

beth.maddux
Participant
Participant

So if I create a new material within Inventor there is a description field. I want to pull that description into a custom Iproperty within the model using iLogic. Is there a way to do that or is there a better place to try and look?

0 Likes
1,173 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi beth.maddux,

 

This is more of an API question than illogic, so I searched over here:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

and came up with the example below.

 

It looks at materials in the document (rather than the materials in the material library), and then looks through the asset values of the current material, that have a string type, which should include the Description.

 

but for some reason it doesn't turn up, even though Keyword, Cost, etc all show up.

 

Not sure why this is the case. You might create a new post on the Customization forum, and ask why description doesn't show up, and link back to this post.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

'get the current material 
oCurrentMat = iProperties.Material

Dim oPartDoc as PartDocument
oPartDoc = ThisDoc.Document
Dim oAssetLib As AssetLibrary
oAssetLib = ThisApplication.AssetLibraries.Item("Shick Material Library")

'look through all of the materials in the document 
'( not the asset library in this case)
Dim material As MaterialAsset
For Each material In  oPartDoc.MaterialAssets
	If oCurrentMat = material.DisplayName Then
	MessageBox.Show("Current Material: " & oCurrentMat, "iLogic")
	For Each oValue As AssetValue In material
		If oValue.ValueType = AssetValueTypeEnum.kAssetValueTypeString Then
			Dim oStringAssetValue As StringAssetValue
			oStringAssetValue = oValue	
			MessageBox.Show(oValue.Name & ": " & oStringAssetValue.Value, "iLogic")
		End If
	Next
	End If
Next

EESignature

0 Likes
Message 3 of 4

blandb
Mentor
Mentor

Hey Curtis, 

 

What if I wanted to use what you have here and just pull the "Model" & "Class" from the material and place into custom iProperties?

Autodesk Certified Professional
0 Likes
Message 4 of 4

mslosar
Advisor
Advisor

If the subproperties of a material aren't directly accessible, then you'll need to use something like the above code to access the field.

 

Once you access that field, you'll have to set the iproperty in question to that value. Something like:

 

SyntaxEditor Code Snippet

iProperties.Value("Custom", "your_custom_iprop") = value

Where value is the field the code in the above post.

 

If you need more help on that you'll need to go to the customization group.

 

0 Likes