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
in reply to: donald_leigh

Hi Again @Curtis_Waguespack 

 

The rule you amended above will move the view label of the 1st base view only a set distance below the lowest dimension on the whole drawing. if there is another view, with dimensions (In the Y direction), that is lower then the base view the label of the base view will move below tat other view.

 

I have changed the rule (See below) to move all the view labels but its moving them all based on the rule dim above and places them in line with each other.

 

What I would like is the rule above to run on only 1 view at a time, and move the view label based on that view only.

 

i hope this is making sense?

 

new rule:

 
Public Sub Main
	Call RepositionDrawingViewLabels
End Sub

Private Sub RepositionDrawingViewLabels()
	'Set a reference to the drawing document.
	'This assumes a drawing document is active.
	Dim oApp = ThisApplication
	Dim oDoc As DrawingDocument
	oDoc = oApp.ActiveDocument
	
	'Set a reference to the active sheet.
	Dim oActiveSheet As Sheet
	oActiveSheet = oDoc.ActiveSheet
	
	'Set a reference to the TransientGeometry on active sheet.
	Dim oTG As TransientGeometry
	oTG = oApp.TransientGeometry
	
	'This Drawing Document Select Set
	Dim oSelectset As SelectSet = oDoc.SelectSet
	oSelectset.Clear()
	
	Dim oSheet As Sheet = oDoc.ActiveSheet
	Dim oViews As DrawingViews = oActiveSheet.DrawingViews
	Dim oView As DrawingView = oSheet.DrawingViews.Item(1) ' Assuming you're working with the first view
	
	For Each oView In oViews
		oSelectset.Select(oView)
		
		'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 DrawingViewLabel = oView.Label
		
		'Define the new position for the label
		Dim newX As Double = oLabel.Position.X
		Dim newY As Double = lowestY - 1 ' Adjust this value as needed for spacing
		
		Dim oPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(newX, newY)
		
		'Move the label to the new position
		oLabel.Position = oPoint
		
		'Refresh the drawing to see the changes
		oSheet.Update()
	Next
	iLogicVb.UpdateWhenDone = True
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.Text.Origin
		Dim dimY As Double = dimPosition.Y
	
		If dimY < lowestY Then
			lowestY = dimY
		End If
	Next

	Return lowestY
End Function

 

Donald