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: 

No update of Unit Quantity

1 REPLY 1
Reply
Message 1 of 2
^_^clovis^_^
426 Views, 1 Reply

No update of Unit Quantity

Hello,

I'm updating the "Units" of a document but the "Unit Quantity" doesn't update.

 

pic01- With a vba macro I change the linear Dim Display Precision using

"oObject.UnitsOfMeasure.LengthDisplayPrecision = 1" then update the part

"oObject.Update". I've tried with oObject.Update2 (true) but the result is the same.

 

pic02- the Unit Quantity format doesn't get updated.

 

pic03- When I change manually the units and re-open the document the update is finally done.

 

How can I reach this result with vba? thanks

 

Any help would be greatly appreciated!

pic1

1 REPLY 1
Message 2 of 2
ianteneth
in reply to: ^_^clovis^_^

Hi! I was able to reproduce your observation with the code below. I also tried to update the precision using an "Update" method, however it did not work. 

 

Sub Main()
	'Get the drawing. Assume a part is open.
	Dim part As Inventor.PartDocument = ThisDoc.Document
	
	'Show old unit quantity value
	MessageBox.Show("Old Precision: " & part.UnitsOfMeasure.LengthDisplayPrecision & vbNewLine & _
	"Old Unit Quantity: " & part.ComponentDefinition.BOMQuantity.UnitQuantity)
	
	'Update display precision
	part.UnitsOfMeasure.LengthDisplayPrecision = 3
	
	'Show the unit quantity again to see if value changed
	MessageBox.Show("New Precision: " & part.UnitsOfMeasure.LengthDisplayPrecision & vbNewLine & _
	"Old Unit Quantity: " & part.ComponentDefinition.BOMQuantity.UnitQuantity)
End Sub

 

I also noticed that the "Base Quantity" property shows the updated display precision (See image below). And I was able to manually update it by selecting another parameter and then re-selecting the right parameter. I haven't tested it, but maybe using the "SetBaseQuantity" method to be another parameter and changing it back would trigger the update of the display precision. Hope this helps someone to figure this out!

 

Capture.JPG

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report