Center drawing dimension text and save drawing

Center drawing dimension text and save drawing

Pav3L
Advocate Advocate
472 Views
3 Replies
Message 1 of 4

Center drawing dimension text and save drawing

Pav3L
Advocate
Advocate

Hi,

I have a model of a part that has 3 size options. I want the drawing associated with this part to be automatic.

I almost got it done, but when I change the drawing view scale based on the model size, the dimension text is not centered. In another topic I found a rule that centers the dimension text, which works fine when I run it manually when the drawing is open, but when it should be automatic (run by another rule) it does not work, well the rule is executed but the text is not centered before the drawing save and close operation.

 

1st rule that changes the drawing view scale and then executes the second rule.

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oModelDoc As PartDocument = oDoc.ReferencedDocuments.Item(1)
Dim oDimensionA As Double = (oModelDoc.ComponentDefinition.Parameters.Item("Width").Value) * 10
Dim oScale As String
Dim oView As DrawingView

If oDimensionA = 300 Then
	oScale = "1 : 2"
ElseIf oDimensionA = 450 Then
	oScale = "1 : 2.5"
ElseIf oDimensionA = 650 Then
	oScale = "1 : 3"
End If

For Each oView In oDoc.ActiveSheet.DrawingViews
	If oView.ScaleFromBase = False
		oView.ScaleString = oScale
	End If
Next

RuleParametersOutput()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True

iLogicVb.RunRule("Center Dimension Text")

 

 

2nd rule "Center Dimension Text" that should center the dimension text. When I run it manually after the 1st rule the dimension text is centered, but when the rule is run automatically by the 1st rule, then the text is not centered when I open the drawing.

 

Dim oDoc As DrawingDocument = ThisDoc.Document

'Set a reference to the active sheet
Dim oSheet As Sheet
Dim oDrawingDim As DrawingDimension

'Iterate over all dimensions in the drawing and center them if they are linear or angular.
For Each oSheet In oDoc.Sheets
	For Each oDrawingDim In oSheet.DrawingDimensions
		If TypeOf oDrawingDim Is LinearGeneralDimension Or
			TypeOf oDrawingDim Is AngularGeneralDimension Then
			Call oDrawingDim.CenterText
		End If
	Next
Next

RuleParametersOutput()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True

oDoc.Save
oDoc.Close

 

 

I cannot share the file for copyright reasons, but if needed I could create a sample file of something else.

0 Likes
Accepted solutions (1)
473 Views
3 Replies
Replies (3)
Message 2 of 4

Pav3L
Advocate
Advocate

Here is a neutral file that shows the behavior. In the model, change the "SIZE" parameter and the drawing opens and changes automatically, but the dimension text is not centered.

0 Likes
Message 3 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Pav3L 

 

You might be able to do this by changing this setting in the drawing/template.

 

Tools tab > Options panel > Document Settings button>Drawing tab

 

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

 

 

 

Reference Link: Drawing Tab Reference (Document Settings)

 

Curtis_Waguespack_0-1699366140151.png

 

EESignature

Message 4 of 4

Pav3L
Advocate
Advocate
Hi @Curtis_Waguespack

That did the trick, thanks.
0 Likes