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

Ilogic move drawingdimensions

Anonymous

Ilogic move drawingdimensions

Anonymous
Not applicable

Hi, 

 

I am trying to move some drawingdimensions with ilogic, but it is not working. 

with the help of the VBA tool i could find the coordinates of the dimensionlines, but it looks they are read-only. 

Why are these dimensions read only, and can't be moved with ilogic?

for my code i have a simple drawing that has 4 dimensions on it. 

 

Dim osheet As Sheet = ThisApplication.ActiveDocument.activesheet
Dim oview As DrawingView = osheet.DrawingViews(1)
Dim dimension As GeneralDimension

For Each dimension In osheet.DrawingDimensions
	Trace.WriteLine(dimension.ModelValue)
	
	If dimension.DimensionLine.direction.y = 1 Then
		Trace.WriteLine("Direction y=1")
		dimension.DimensionLine.MidPoint.X = oview.Center.X - (oview.Width * 0.5) - 0.6
	ElseIf dimension.DimensionLine.direction.y = -1 Then
		Trace.WriteLine("Direction y=-1")
		dimension.DimensionLine.MidPoint.X = oview.Center.X + (oview.Width * 0.5) + 0.6
	ElseIf dimension.DimensionLine.direction.x = 1 Then
		Trace.WriteLine("Direction x=1")
		dimension.DimensionLine.MidPoint.Y = oview.Center.Y - (oview.Height * 0.5) -0.6
	ElseIf dimension.DimensionLine.direction.x = -1 Then
		Trace.WriteLine("Direction x=-1")
		dimension.DimensionLine.MidPoint.Y = oview.Center.Y + (oview.Height * 0.5) + 0.6
	End If
	
Next
Trace.WriteLine("rule done")

i also tried to create a point2D and then move the MidPoint of the dimensionline to the point. but that also doesn't work

 

I am able to read out all the values of the dimensionline, so ilogic can find the correct properties.

Trace.WriteLine(dimension.DimensionLine.MidPoint.X & " " & dimension.DimensionLine.MidPoint.Y)

Kind regards,

 

Geert

 

0 Likes
Reply
Accepted solutions (2)
1,115 Views
4 Replies
Replies (4)

clutsa
Collaborator
Collaborator
Accepted solution

You're on the right track with the point2D but try moving the Text.Origin

dimension.Text.Origin = ThisServer.TransientGeometry.CreatePoint2D((oview.Center.X - (oview.Width * 0.5) - 0.6), dimension.Text.Origin.Y)

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes

JelteDeJong
Mentor
Mentor
Accepted solution

i see that clutsa just answerd your question befor i could post my code. i will post it anyway because it's a bit more extensive but comes down to the same.

        Dim doc As DrawingDocument = ThisApplication.ActiveDocument
        Dim oSheet As Sheet = doc.ActiveSheet

        Dim oview As DrawingView = osheet.DrawingViews(1)
        'Dim dimension As GeneralDimension

        Dim oTg = ThisApplication.TransientGeometry

        For Each dimension As DrawingDimension In oSheet.DrawingDimensions

            Dim midPointText As Point2d = dimension.Text.Origin
            Dim midPointView = oview.Center
            Dim textHeight = 0.5

            Dim newX As Double
            Dim newY As Double

            Dim deltaX As Double = (oview.Width * 0.5) + 0.6
            Dim deltaY As Double = (oview.Height * 0.5) + 0.6

            If (midPointText.X > midPointView.X + oview.Width / 2) Then
                newX = midPointView.X + deltaX
                newY = midPointView.Y
            End If
            If (midPointText.X < midPointView.X - oview.Width / 2) Then
                newX = midPointView.X - deltaX - textHeight
                newY = midPointView.Y
            End If

            If (midPointText.Y > midPointView.Y + oview.Height / 2) Then
                newX = midPointView.X
                newY = midPointView.Y + deltaY + textHeight
            End If
            If (midPointText.Y < midPointView.Y - oview.Height / 2) Then
                newX = midPointView.X
                newY = midPointView.Y - deltaY
            End If

            Dim newMidPoint As Point2d = oTg.CreatePoint2d(newX, newY)

            dimension.Text.Origin = newMidPoint
        Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Anonymous
Not applicable

Thanks!! that worked great!!

 

but as clutsa did in the code, when y or x don't change they should be:

 

newY = dimension.Text.Origin.Y

or

newX = dimension.Text.Origin.X

then they move like they should.

 

thanks again.

 

vvvxxvvv333
Enthusiast
Enthusiast

a good rule of thumb is to have one dimension per side. And how should it be changed if there were more dimensions? On the left are three dimensional lines.

0 Likes