Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic mass over-ride

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
gazadder
855 Views, 2 Replies

Ilogic mass over-ride

Spoiler
 

 

 

I am having an issue where I am over-riding the mass of a part within an assembly using Ilogic. However, although this mass is successfully written the part never seems to save this over-ridden mass in the assembly and when closing and re-opening the assembly it is back at its original mass value.

 

This is the line of code for writing to the part:-

 

iProperties.MassOfComponent("IMPELLER_C_of_G") =

 

The onyl way I can get the part to kep its over-ridden mass is to also write somehting into another iproperty valve like a part number which isn't practical.

 

2 REPLIES 2
Message 2 of 3

Hi gazadder,

 

Try this snippet. Basically we need to identify the assembly component occurence down to the file document, and then you can "dirty" the file so it will get saved.

 

'define top level assembly
Dim oAssDoc As AssemblyDocument = ThisApplication.ActiveDocument
'define component occurence
Dim compOcc as Inventor.ComponentOccurrence
compOcc = Component.InventorComponent("Base:1")
'define component file definition
Dim compDef as Inventor.ComponentDefinition
compDef = compOcc.Definition
'define file document
Dim compDoc as Inventor.Document
compDoc = compDef.Document
' Override the mass
iProperties.MassOfComponent(compOcc.Name) = 777
'dirty the file so it will get saved
compDoc.Dirty = True

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

Message 3 of 3

Thanks Curtis,

 

So the conclusion seems to be a user cannot over-write the mass of a part in an assembly using code as the file technically doesn't change so a save is not completed. Even when the part is edited in the assembly using the UI the mass is greyed out so that it can't be edited.

 

The work arounds are all as below:-

 

1:   Force something else in the file to change so it is "dirty"

 

iProperties.MassOfComponent("IMPELLER_C_of_G") = 20

iProperties.Value("IMPELLER_C_of_G", "Project", "Part Number") = "IMPELLER_C_of_G"

 

 

2:   Tell the file that it is "dirty"

 

'define top level assembly
Dim oAssDoc As AssemblyDocument = ThisApplication.ActiveDocument
'define component occurence
Dim compOcc as Inventor.ComponentOccurrence
compOcc = Component.InventorComponent("IMPELLER_C_of_G ")
'define component file definition
Dim compDef as Inventor.ComponentDefinition
compDef = compOcc.Definition
'define file document
Dim compDoc as Inventor.Document
compDoc = compDef.Document
' Override the mass
iProperties.MassOfComponent(compOcc.Name) = 777
'dirty the file so it will get saved
compDoc.Dirty = True

 

 

3:   Force a save on the part

 

Dim componentOccurrence As Inventor.ComponentOccurrence = Component.InventorComponent("IMPELLER_C_of_G")

Dim massProperties As Inventor.MassProperties = componentOccurrence.MassProperties

massProperties.Mass = 23

Dim definition As Inventor.ComponentDefinition = componentOccurrence.Definition

Dim document As Inventor.Document = definition.Document

document.Save

 

4:  Opens the part to be edited in the background while rule is running.

 

Dim componentOccurrence As Inventor.ComponentOccurrence = Component.InventorComponent("IMPELLER_C_of_G")

componentOccurrence.Edit()

Dim massProperties As Inventor.MassProperties = componentOccurrence.MassProperties

massProperties.Mass = 23

componentOccurrence.ExitEdit(Inventor.ExitTypeEnum.kExitToParent)

 

 

 

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

Post to forums  

Autodesk Design & Make Report