Dimension text positon

Dimension text positon

atomic.lex
Enthusiast Enthusiast
3,261 Views
3 Replies
Message 1 of 4

Dimension text positon

atomic.lex
Enthusiast
Enthusiast

I've been writing a script to change the position of the dimension text, but it's not working as expected. Can anyone tell me why and how it might work?

P.S. I set the dimension text to the center position (it works) and after that try to move it by changing the X and Y coordinates (it doesn't work).

Sub ChangeDimTextPosition(DimName As String, DimX As Double, DimY As Double)
	Dim oDoc As DrawingDocument = ThisDoc.Document
	Dim oSheets As Sheets = oDoc.Sheets
	Dim oViews As DrawingViews
	Dim oName As String
	Dim oCoords() As Double = {0,0}
	For Each oSheet As Sheet In oSheets
		oSheet.Activate
		oViews = oDoc.ActiveSheet.DrawingViews
		For Each oView As DrawingView In oViews
			ViewName = oView.Name
			For Each oDim As DrawingDimension In oSheet.DrawingDimensions
				If oDim.Retrieved Then oName = oDim.RetrievedFrom.Parameter.Name Else oName = ""
				If oName = DimName Then
					Call oDim.CenterText
					oCoords(0) = oDim.Text.Origin.X + DimX
					oCoords(1) = oDim.Text.Origin.Y + DimY
					Call oDim.Text.Origin.PutPointData(oCoords)
					Exit Sub
				End If
			Next oDim
		Next oView
	Next oSheet
End Sub

 

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

Cadkunde.nl
Collaborator
Collaborator

If its not working as expected, can you tell us what you were expecting or trying to accomplish

0 Likes
Message 3 of 4

atomic.lex
Enthusiast
Enthusiast

Sorry,

I set the dimension text to the center position (it works) and after that try to move it by changing the X and Y coordinates (it doesn't work).

0 Likes
Message 4 of 4

Cadkunde.nl
Collaborator
Collaborator
Accepted solution
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim pnt As Inventor.Point2d = oTG.CreatePoint2d(oCoords(0), oCoords(1))
oDim.Text.Origin = pnt

 

0 Likes