Dimension Text is rotated by 90° when rearranging dimension with iLogic rule

Dimension Text is rotated by 90° when rearranging dimension with iLogic rule

Darrell.johnson
Enthusiast Enthusiast
641 Views
6 Replies
Message 1 of 7

Dimension Text is rotated by 90° when rearranging dimension with iLogic rule

Darrell.johnson
Enthusiast
Enthusiast

Hello, I created an iLogic Rule to arrange the dimensions in a drawing document automatically.

 

Private Sub ReArrangeDrawingDimensions(oSheet As Inventor.Sheet, drawingView As Inventor.DrawingView, dimensionName As String, Optional xCoord As Double = 0, Optional yCoord As Double = 0)
	
	Dim oGeneralDimensions As GeneralDimensions
	oGeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions
	
	Dim xCoordComp, yCoordComp As Double
	Dim oWidthDim, oHeightDim, oDepthDim As LinearGeneralDimension
	Dim oCompDim As LinearGeneralDimension
	Dim newPosComp As Point2d
	
	For Each oGeneralDimension As GeneralDimension In oGeneralDimensions
		If oGeneralDimension.AttributeSets.Count >0 Then
			If oGeneralDimension.AttributeSets.Item(1).Name = dimensionName Then
				oCompDim = oGeneralDimension
			End If
		End If
	Next

	If xCoord = 0 Then
		xCoordComp = oCompDim.Text.Origin.X
	Else
		xCoordComp = xCoord
	End If
	
	If yCoord = 0 Then
		yCoordComp = oCompDim.Text.Origin.Y
	Else
		yCoordComp = yCoord
	End If
	
	newPosComp = ThisApplication.TransientGeometry.CreatePoint2d(xCoordComp, yCoordComp)
	
	oCompDim.Text.Origin = newPosComp
End Sub

 

For most of the dimensions this rule works just fine but one dimension is giving me trouble.

 

Darrelljohnson_1-1682670471525.png

 

The Dimension Text is rotated by 90 ° and I can't figure out why.

The only thing different from the other dimensions is that the DimensionLine.Direction.Y Property of the dimension is -1 instead of 1, but this property is read-only.

 

0 Likes
Accepted solutions (1)
642 Views
6 Replies
Replies (6)
Message 2 of 7

Darrell.johnson
Enthusiast
Enthusiast

I just realized that this dimension is the only one placed on circular geometry.

 

Darrelljohnson_1-1682672221153.png

 

By putting a sketch on the hole and placing lines on the circular geometry, it works as intended.

 

Darrelljohnson_2-1682672389888.png

 

 

0 Likes
Message 3 of 7

Darrell.johnson
Enthusiast
Enthusiast

The above mentioned method of placing lines on circular geometry, doesn't work either, for some weird reason it just worked one time.

0 Likes
Message 4 of 7

vvvxxvvv333
Enthusiast
Enthusiast

can you share the file where that rule works? There is an error on my screen

0 Likes
Message 5 of 7

Darrell.johnson
Enthusiast
Enthusiast
Sub Main
	Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oSheet As Sheet = oDoc.Sheets(1)
	Dim dimensionName As String = "test"
	
	If oSheet.DrawingDimensions(1).AttributeSets.Count = 0 Then
		oSheet.DrawingDimensions(1).AttributeSets.Add(dimensionName)
	End If
	
	Dim oView As DrawingView = oSheet.DrawingViews(1)
	Dim xCoord As Double = oView.Left + oView.Width + 1
	Dim yCoord As Double = oView.Top - oView.Height - 1
	
	ReArrangeDrawingDimensions(oSheet, oView, dimensionName, xCoord, yCoord)
End Sub

Private Sub ReArrangeDrawingDimensions(oSheet As Inventor.Sheet, drawingView As Inventor.DrawingView, dimensionName As String, Optional xCoord As Double = 0, Optional yCoord As Double = 0)
	
	Dim oGeneralDimensions As GeneralDimensions
	oGeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions
	
	Dim xCoordComp, yCoordComp As Double
	Dim oWidthDim, oHeightDim, oDepthDim As LinearGeneralDimension
	Dim oCompDim As LinearGeneralDimension
	Dim newPosComp As Point2d
	
	For Each oGeneralDimension As GeneralDimension In oGeneralDimensions
		If oGeneralDimension.AttributeSets.Count >0 Then
			If oGeneralDimension.AttributeSets.Item(1).Name = dimensionName Then
				oCompDim = oGeneralDimension
			End If
		End If
	Next

	If xCoord = 0 Then
		xCoordComp = oCompDim.Text.Origin.X
	Else
		xCoordComp = xCoord
	End If
	
	If yCoord = 0 Then
		yCoordComp = oCompDim.Text.Origin.Y
	Else
		yCoordComp = yCoord
	End If
	
	newPosComp = ThisApplication.TransientGeometry.CreatePoint2d(xCoordComp, yCoordComp)
	
	oCompDim.Text.Origin = newPosComp
End Sub
0 Likes
Message 6 of 7

Darrell.johnson
Enthusiast
Enthusiast

@vvvxxvvv333: Here is the  file where the rule works. Which kind of error are you getting?

0 Likes
Message 7 of 7

Darrell.johnson
Enthusiast
Enthusiast
Accepted solution

I found a solution. If you center the dimension text before rearranging it, the text orientation doesn't change an is displayed as intented.

 

Private Sub CenterDrawingDimensions(oSheet As Inventor.Sheet, dimensionName As String)
	For Each oDim As DrawingDimension In oSheet.DrawingDimensions
		If oDim.AttributeSets.Count >= 1 Then
			If oDim.AttributeSets(1).Name = dimensionName Then
				oDim.CenterText
			End If
		End If
	Next
End Sub

 

0 Likes