Get and set alternate units.

Get and set alternate units.

Anonymous
Not applicable
435 Views
2 Replies
Message 1 of 3

Get and set alternate units.

Anonymous
Not applicable

I need a way to get and set alternate units per a drawing dimension in Inventor using VBA.

I can't change the dimension style.

Just like we can do in the API with precision and Tolerance in General Dimension.

 

Pleas help me..

0 Likes
436 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Just a suggestion, assuming the dimension's model value is in inches, and you want your 'alternate' units to be milimeters.  You could try something like code.  It obviously isn't customized to your situation, but the methods are there. This should modify all dimensions on all sheets of the active drawing to showing the milimeter value of the ModelValue right below the ModelValue (again assuming the ModelValue is in Inches).

 

Dim oDoc As DrawingDocument
oDoc = ThisDrawing.Document

Dim oVal As Double

For Each oSheet As Sheet In oDoc.Sheets
	For Each oDwgDim As DrawingDimension In oSheet.DrawingDimensions
		If oDwgDim.ModelValueOverridden = True Then
			oVal = oDwgDim.OverrideModelValue
		ElseIf oDwgDim.ModelValueOverridden = False Then
			oVal = oDwgDim.ModelValue
		End If
		'You could use a MessageBox or InputListBox here to ask which Alt Units you want to show.
		'You could also set up the math factors as Local Variables for the other Unit conversins here if needed.
		'This is just converting adding a new line under the existing ModelValue, then converting its Inches to Milimeters.
		oDwgDim.Text.FormattedText = "" & vbNewLine & (oVal*25.4).ToString & "mm"
	Next
Next

I hope this helps.

If this solves your problem or answers your questions, please click 'Accept As Solution'.

Or if this helps you out in reaching your goal, please click 'Like'.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Sorry, that was in regular iLogic, not using VBA, but its easily translatable.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes