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: 

iLogic to Access Material Information

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
daleschumann
4627 Views, 16 Replies

iLogic to Access Material Information

I'm not sure if this is possible through the API or not, but there are a lot of smart folks on here so let's give it a shot. I would like to make a rule that will take information from the material "Descriptive Information" "Comments" line and put it in the Stock Number iProperty. We have a large library of custom materials and I want to put the raw material stock number in the comments field then use iLogic to extract it and apply it to the Stock Number whenever the material is changed.

 

16 REPLIES 16
Message 2 of 17

Hello Dale,

 

Yes you can.

 

Here is an iLogic rule that does that.

 

 Dim oPartDoc As Inventor.PartDocument = ThisDoc.Document
  Dim oRawMatNo As String = oPartDoc.ActiveMaterial.Item("physmat_Comments").Value
  MsgBox(oRawMatNo)
  iProperties.Value("Project", "Stock Number") = oRawMatNo

 (delete the MSGbox line)

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 17

Exactly what I needed, thanks!

Message 4 of 17

Currently I am using the above rule for my active materials which works very well, but I was wondering if there is a way to access an inactive material comment based on a multi-value text parameter that matches an inactive material name.

 

 

Message 5 of 17


Hi

Is there a list of all the names from the material information properties?

  Dim oRawMatNo As String = oPartDoc.ActiveMaterial.Item("physmat_Comments").Value

For example: physmat_Comments is for the Identity Tab -> Comments box

                        physmat_Manufacturer is for the Identity Tab -> Manufacturer

 

How to access in the Physical Tab the boxes like Name, Description, Keywords, Source etc.

 

Thanks


 

Message 6 of 17

try:

 

Physmat_Comments

Physmat_Cost

Physmat_Keynote

Physmat_Keywords

Physmat_Label

Physmat_Manufacturer

Physmat_Mark

Physmat_Model

Physmat_Type

Physmat_URL

 

Appearance and Physical tabs

oPartDoc.Activematerial.PhysicalPropertiesAsset.item(“.....”)

structural_density

structural_behavior

etc..

Generic_self_illum_color_temperature

Generic_self_illum_filter_map

generic_self_illum_Luminance

Generic_Transparency

Etc, 

(do a for each item and list the names….)

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 7 of 17

pHysical ...

 

        Dim oPartDoc As PartDocument =  ThisDoc.Document

        Dim ActiveMat As Asset = oPartDoc.ActiveMaterial
        'list all Identity AssetValues:
        For Each oAssetValue As AssetValue In ActiveMat
            MessageBox.Show(oAssetValue.Name)
        Next

        Dim ActiveApperancePhysical As Asset = oPartDoc.ActiveMaterial.PhysicalPropertiesAsset
        'list all Appearance and Physical
		msgbox("")
        For Each oApperancePhysical As AssetValue In ActiveApperancePhysical
            MessageBox.Show(oApperancePhysical.Name)
        Next
If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 8 of 17

Thank you very much @HermJan.Otterman !

That's exactly what i was looking for. Unfortunately I can't find where to accept as solution!

 

Best regards

j

Message 9 of 17

great that you found your solution.

the accept is only if you created the initial question.

thanks

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 10 of 17

with this code you go through ALL material in you project file:

 

Dim AssetLibs As AssetLibraries = ThisApplication.AssetLibraries
Dim AssetLib As AssetLibrary
For Each AssetLib In AssetLibs
	Dim oMaterialAssets As AssetsEnumerator = AssetLib.MaterialAssets
	Dim oMaterial As MaterialAsset
	For Each oMaterial In oMaterialAssets
		msgbox(oMaterial.displayname)
	Next
Next

 where the messagebox is, you can put the code from the previous answer to get to the properties

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 11 of 17
mdiyer
in reply to: HermJan.Otterman

This is great information...

Perhaps I'm missing it here, but what I really need is to pull the Appearance Name associated with a material. Material/Appearance/Information/Name

 

Capture2.JPG

Message 12 of 17
bradeneuropeArthur
in reply to: mdiyer

 

Public Sub asse()

Dim a As Application
Set a = ThisApplication

Dim oAsset As Asset
Dim oAssets As Assets

Set al = a.AssetLibraries.Item("YOUR MATERIAL LIBRARY NAME")

Dim m As MaterialAsset
For Each oAsset In al.MaterialAssets
If oAsset.DisplayName = "YOUR MATERIAL" Then
Debug.Print oAsset.Name
Set m = a.AssetLibraries.Item("YOUR MATERIAL LIBRARY NAME").MaterialAssets.Item(oAsset.Name)

MsgBox m.AppearanceAsset.DisplayName
MsgBox m.DisplayName
End If

Next

 

 

 

Regards, 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 13 of 17

I explored your posting. Great help. However, my need is to retrieve mostly the material of the current part document. Like to retrieve other data Other data (appearance) as well.

 

Message 14 of 17
TRM_Plan
in reply to: mdiyer

Hi!

 

I need some help for the following problem. I would like to get information about Material Editor / Physical / Name.

I will create a code when i will filter the surface treatment. When i choose the "steel", i can select between black oxided, nickel plated, ... When i choose the "aluminium", i can select anodized.

I need this Physical name, but i can't know how i get this parameter.

 

Tthanks

Message 15 of 17
ic198
in reply to: HermJan.Otterman

Hi Herm Jan,

 

Do you know how to access the Material Description on the Identity tab? I don't see it on your list, and this thread suggests it might not be available?

https://forums.autodesk.com/t5/inventor-forum/material-description-as-custom-iproperty/td-p/6913143

 

Thanks for your help

Message 16 of 17
TRM_Plan
in reply to: ic198

Hello,

 

Unfortunately I can replay at now.

I use the following code to list the physical information. And I can't find the Name of Physical. I can't find this in API table.

 

Dim oPartDoc As Inventor.PartDocument = ThisDoc.Document

Dim oActivePhysical As Asset = oPartDoc.ActiveMaterial.PhysicalPropertiesAsset
MessageBox.Show(oActivePhysical.Name)
For Each oPhysical As AssetValue In oActivePhysical
MessageBox.Show(oPhysical.Name, "Azonosító")
Dim oPhysMat As String = oPhysical.Value
MessageBox.Show(oPhysMat, "Érték")
Next

 

Message 17 of 17
ic198
in reply to: TRM_Plan

Thanks @TRM_Plan 

@johnsonshiue, do you know why the material description is not available, and seems to be the only property that isn't available? I want access to it because it is easy to update, whereas changing the Name property creates a new material

Material.PNG

 

Thanks

ic198

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

Post to forums  

Autodesk Design & Make Report