Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
J-Camper
in reply to: Mac_W

@Mac_W,

 

Here is an example of using Lists to collect information:

Sub Main
	
	Dim dDoc As DrawingDocument = TryCast(ThisApplication.ActiveDocument, DrawingDocument)
	If IsNothing(dDoc) Then Logger.Debug("Not Run In Drawing Document") : Exit Sub
		
	Dim PickView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View to collection points")
	If IsNothing(PickView) Then Exit Sub ' If nothing gets selected then we're done
	
	Dim CoordinateList As New List(Of List(Of Double))
	
	For Each dc As DrawingCurve In PickView.DrawingCurves
		If IsNothing(dc.MidPoint) Then Continue For 'Skip
		
		Dim MidPointList As New List(Of Double)
		MidPointList.AddRange({dc.MidPoint.X, dc.MidPoint.Y}) 'Add for 3D points: , dc.CenterPoint.Z})
		CoordinateList.Add(MidPointList)
		
	Next
	
	For Each CollectedList As List(Of Double) In CoordinateList
		Dim MessageString As String = Nothing
		
		If CollectedList.Count = 3
			MessageString = "X: " & CollectedList.Item(0) & " | Y: " & CollectedList.Item(1) & " | Z: " & CollectedList.Item(2)' 3D Points
		Else If CollectedList.Count = 2
			MessageString = "X: " & CollectedList.Item(0) & " | Y: " & CollectedList.Item(1)' 2D Points
		End If
		
		Logger.Trace(MessageString)
	Next
	
End Sub

 

It is not the only way to collect information, but it might help you understand value collections.  If you want the objects themselves, you can use an ObjectCollection:

Sub Main
	
	Dim dDoc As DrawingDocument = TryCast(ThisApplication.ActiveDocument, DrawingDocument)
	If IsNothing(dDoc) Then Logger.Debug("Not Run In Drawing Document") : Exit Sub
		
	Dim PickView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View to collection points")
	If IsNothing(PickView) Then Exit Sub ' If nothing gets selected then we're done
	
	Dim DrawingCurveCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	For Each dc As DrawingCurve In PickView.DrawingCurves
		DrawingCurveCollection.Add(dc)
	Next
	
	Dim testingLimiter As Integer = 15 	'Testing purposes only to limit messageboxes if user selects a view with many drawing curves
	Dim TextCounter As Integer = 0 		'Testing purposes only to limit messageboxes if user selects a view with many drawing curves
	Dim selectThis As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet
	
	For Each CollectedDrawingCurve As DrawingCurve In DrawingCurveCollection
		TextCounter += 1
		If TextCounter > testingLimiter Then Exit For 
			
		selectThis.AddItem(CollectedDrawingCurve.Segments(1))
		MessageBox.Show("Highlighted First Segment of a DrawingCurve")
		selectThis.Clear
	Next
	
End Sub