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: 

Changing Material

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
doum90
584 Views, 3 Replies

Changing Material

Hello everyone,

I am currently making a small vb.net program that gets the properties from a source part to a destination part. The problem is I get an error message for some materials while others may work. The material exist in both part so I've ruled that out of the problem. Here is a sample of my code:

 

Dim inv_app As Inventor.Application

       

Dim document As Inventor.Document

       

inv_app = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

       

document = inv_app.ActiveDocument

 

Dim Matiere As Inventor.Property

Matiere = document.PropertySets.Item("Design Tracking Properties").Item("Material")

document.ComponentDefinition.Material.Name = txtMatiere.Text

 

For some materials (ex: Alu-6061 T6), I get this error: (Exception de HRESULT : 0x80004005 (E_FAIL)) while some materials will be just fine (ex: HRS)

 

Does anyone know what could be the problem? instead of txtMatiere.text, I've tried putting a string directly : "Alu-6061 T6" and it worked...

 

Thank you

3 REPLIES 3
Message 2 of 4
doum90
in reply to: doum90

by the way, I've also tried :

inv_app.ActiveDocument.ComponentDefinition.Material = inv_app.StylesManager.Materials.Item(txtMatiere.Text)

but this time I get :  Invalid parameter (Exception de HRESULT : 0x80070057 (E_INVALIDARG))

Message 3 of 4
rob.j.ross
in reply to: doum90

Try txtMatiere.Text.ToString

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Message 4 of 4
doum90
in reply to: rob.j.ross

Thank you very very much. That was the solution it doesn't work for:

inv_app.ActiveDocument.ComponentDefinition.Material = inv_app.StylesManager.Materials.Item(txtMatiere.Text.ToString)

 

but it works when I try it this way:

document.ComponentDefinition.Material.Name = txtMatiere.Text.ToString

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

Post to forums  

Autodesk Design & Make Report