09-09-2019
01:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-09-2019
01:40 PM
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