Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

mass props to 1dp ( 0.1kg)

keithc03GZXH6
Enthusiast

mass props to 1dp ( 0.1kg)

keithc03GZXH6
Enthusiast
Enthusiast

I require the mass props to be reported on the parts list to 1dp ,

I know that I need to update the Document settings / units / linear dim display precision in order to do this 

can anyone assist in the code required to perform this update on all parts in an assembly 

TIA

keithc03GZXH6_0-1693310137535.png

 

0 Likes
Reply
Accepted solutions (1)
258 Views
2 Replies
Replies (2)

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @keithc03GZXH6 . Please try this code:

Sub main
	Dim oDoc As Document = ThisDoc.Document
	If TypeOf oDoc Is AssemblyDocument Then
		For Each oRefDoc As Document In oDoc.AllReferencedDocuments
			If Not oRefDoc.IsModifiable Then Continue For
			ChengeLengthDisplayPrecision(oRefDoc.UnitsOfMeasure, 1)
		Next
	Else If TypeOf oDoc Is PartDocument Then
		Dim oPartDoc As Document = oDoc
		If Not oPartDoc.IsModifiable Then Exit Sub
		ChengeLengthDisplayPrecision(oPartDoc.UnitsOfMeasure, 1)
	End If
End Sub

Private Function ChengeLengthDisplayPrecision(ByVal oUOfM As UnitsOfMeasure,
												ByVal i As Integer)
	oUOfM.LengthDisplayPrecision = i
End Function

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

keithc03GZXH6
Enthusiast
Enthusiast

Andrii 

 

thank you that works as  required 

I owe you a drink sir 

 

Keith