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: 

Material change using Inventor API

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
arunkgvm
4571 Views, 9 Replies

Material change using Inventor API

I changed the material using the vb.net code shown below.but after changing material the object is not updated ,the volume and mass didn't change ..why? any idea. here is my code

 

 

Dim oDoc As PartDocument
oDoc = inventorApp.ActiveDocument

Dim oDTProps As PropertySet
oDTProps = oDoc.PropertySets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}")
Dim oDesignerProp As Inventor.Property
oDesignerProp = oDTProps.ItemByPropId( _
PropertiesForDesignTrackingPropertiesEnum.kMaterialDesignTrackingProperties)
oDesignerProp = oDTProps.Item("Material")
oDesignerProp.Value = "Titanium"
oDoc.Update()

--- *AM* ----
Tags (1)
9 REPLIES 9
Message 2 of 10
arunkgvm
in reply to: arunkgvm

is it change the mass automatically when I change the material from api.?or any changes need to my code??

--- *AM* ----
Message 3 of 10
jdkriek
in reply to: arunkgvm

You are only changing the iProp, that doesn't actually change the material

 

You need to use the ComponentDefinition like this:

 

oDoc.ComponentDefinition.Material.Name = "Titanium"
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 10
jdkriek
in reply to: jdkriek

Actually, this may be the proper way to update everything, but still using ComponentDefinition

 

oDoc.ComponentDefinition.Material = oDoc.Materials.Item("Titanium")
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 10
akosi
in reply to: jdkriek

i tried this and it works but sometimes it takes awhile to update.

 

sometimes i have to go to the other open doc and back to see the updated material...

 

is there a code that can eliminate this delay update? or going back and forth to other open doc?

 

ive added doc.update but still no luck,.,,

 

 

 

inventor 2013

vault 2013

 

 

 

 

 

 

Message 6 of 10
jdkriek
in reply to: arunkgvm

iLogicVb.UpdateWhenDone = True
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 10
akosi
in reply to: arunkgvm

im not using ilogic. im using vba.
Message 8 of 10
jdkriek
in reply to: akosi

Indeed, sorry I forgot.

 

We are actually converting from VBA to External iLogic and VB.NET add-ins at work.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 9 of 10
arunkgvm
in reply to: arunkgvm

Try this this will help me and working fine....just update the mass using this code  after changing the material.

 

 

Dim oPropSet As PropertySet
oPropSet = oPartDoc.PropertySets("Design Tracking Properties")
oPropSet.Item("Material").Value = DropDownList1.SelectedItem.Text
Dim materialDef As Material = oPartDoc.Materials(DropDownList1.SelectedItem.Text)
oPartDoc.ComponentDefinition.Material = materialDef
oPartDoc.Update()
Dim mass As Double = oPartDoc.ComponentDefinition.MassProperties.Mass
oPartDoc.SaveAs("F:\inventor\Proof Of Con\Cube\Cube_update1.ipt", True)
oPartDoc.SaveAs("F:\inventor\Proof Of Con\WebSite14\Documents\Cube_Update.ipt", True)

 

--- *AM* ----
Message 10 of 10
akosi
in reply to: jdkriek

what is the code for selecting something in the model explorer?

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

Post to forums  

Autodesk Design & Make Report