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

Position View Label Below Dimensions

Evening all

 

I have a rule that positions each view label at a set distance below each view. Is there a way to move the label based on the number of dimensions below the view. I found this rule a while ago (And cant find it again) and cant get it to work. Can anyone help me out please 

 

Donald

Inventor 2024

 

 

Sub Main

    Dim oDoc As DrawingDocument = ThisDoc.Document
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oView As DrawingView = oSheet.DrawingViews.Item(1) ' Assuming you're working with the first view

    ' Get the lowest Y position of all dimensions on the drawing sheet
    Dim lowestY As Double = GetLowestDimensionY(oSheet)

    ' Get the label associated with the view
    Dim oLabel As DrawingLabel = oView.Label

    ' Define the new position for the label
    Dim newX As Double = oLabel.Position.X
    Dim newY As Double = lowestY - 10 ' Adjust this value as needed for spacing

    ' Move the label to the new position
    oLabel.Move(New Point2d(newX, newY))

    ' Refresh the drawing to see the changes
    oSheet.Update()

End Sub

Function GetLowestDimensionY(sheet As Sheet) As Double
    Dim lowestY As Double = Double.MaxValue

    For Each oDim As GeneralDimension In Sheet.DrawingDimensions
        Dim dimPosition As Point2d = oDim.Position
        Dim dimY As Double = dimPosition.Y

        If dimY < lowestY Then
            lowestY = dimY
        End If
    Next

    Return lowestY
End Function