Access to drawing view across attached sketched symbol.

Access to drawing view across attached sketched symbol.

mikazakov
Advocate Advocate
116 Views
1 Reply
Message 1 of 2

Access to drawing view across attached sketched symbol.

mikazakov
Advocate
Advocate

Hi,

User attached sketched symbol to drawing view.

How get drawing view object for this sketched symbol across API?

0 Likes
117 Views
1 Reply
Reply (1)
Message 2 of 2

jnowel
Advocate
Advocate

You can get the DrawingView Object by checking the SketchSymbol's Leader Properties.
Sample code below where it iterates on all the SkectchedSymbols on active Sheet and try getting the attached drawing views.

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
If oSheet.SketchedSymbols.Count = 0 Then Exit Sub
	
For i = 1 To oSheet.SketchedSymbols.Count
	
	Dim oSymbol As SketchedSymbol =  oSheet.SketchedSymbols(i)
	Dim oViewList As New List(Of DrawingView)
	Dim oViewNames As String = ""
	If oSymbol.Leader.HasRootNode Then
		For k = 1 To oSymbol.Leader.AllNodes.Count
			Dim oNode As LeaderNode = oSymbol.Leader.AllNodes(k)
			Try
				Dim oParent As Object = oNode.AttachedEntity.Geometry.Parent				
				If TypeOf oParent Is DrawingView Then
					'it is possible for a sketchedsymbol to have more than 1 DrawingViews attached with multiple leaders
					oViewList.Add(oParent)
					'Exit For 'enable this if you want to get the the first DrawingView the leader is attached on
				End If	
			Catch
			End Try
		Next
	End If
	
	If  oViewList.Count = 0 Then
		Logger.Info("Symbol # " & i & " - No DrawingView Attached")
	Else
		For k = 0 To oViewList.Count - 1
			oViewNames = oViewNames & oViewList(k).Name & ", "
		Next
			
		Logger.Info("Symbol # " & i & " - " & oViewNames)
	End If
	
Next

0 Likes