- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)
Mass Override for Each Model State
Custom Glyph Icon for iMates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.