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
Solved! Go to Solution.
Solved by rob.j.ross. Go to Solution.
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))
Try txtMatiere.Text.ToString
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