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

Turn off Sketch Symbol Leader

Im looking for a way to toggle all sketch symbols leaders off. I have the code below to attempt this but the .Leader property is read only.

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oSketchedSymbols As SketchedSymbols = oSheet.SketchedSymbols

For Each oItem As SketchedSymbol In oSketchedSymbols
		
oItem.LeaderVisible = False
oItem.Leader 'THIS IS READ ONLY???
	
Next   

 Does anyone else know how to solve this?

Labels (4)
mfoster9TD82
in reply to: C_Haines_ENG

You may need to get the placement and sketch symbol definition from the existing sketch symbol, delete it and place another one using SketchedSymbols.Add(). It doesn't really looks like you can remove leaders from sketch symbols, but you can add them...


Edit:

I was mistaken. After fooling around with it more, you can delete the all the Nodes in the leader of each sketch symbol:

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oSketchedSymbols As SketchedSymbols = oSheet.SketchedSymbols

For Each oItem As SketchedSymbol In oSketchedSymbols
		
	If Not oItem.Leader Is Nothing AndAlso Not oItem.Leader.AllNodes Is Nothing Then
		While Not oItem.Leader.AllNodes Is Nothing AndAlso oItem.Leader.AllNodes.Count > 0 
			oItem.Leader.AllNodes(1).Delete
		End While
	End If
Next

 

edit2: code fix

 

C_Haines_ENG
in reply to: mfoster9TD82

Inventor doesnt seem to like this line:

 

oItem.Leader.AllNodes(1).Delete

 

Class not registered, incorrect parameter, etc. 

mfoster9TD82
in reply to: C_Haines_ENG

What version of inventor are you using?
And are you getting that in a compiler error or a runtime error?

Dim d As DrawingDocument = ThisDrawing.Document
Dim s As Sheet = d.ActiveSheet
Dim sss As SketchedSymbols = s.SketchedSymbols

	For Each ss As SketchedSymbol In sss
	Try	
		ss.Leader.AllLeafNodes.Item(1).Delete
Catch
		
	End Try
Next

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

A.Acheson
in reply to: C_Haines_ENG

Hi @C_Haines_ENG 

Is your goal to switch off the leader visibility

You might want to put in an error trap for any that are off also. If you go about deleting then you have nothing to bind the symbol to the view.

Syntax

SketchedSymbol.LeaderVisible() As Boolean

Property Value

This is a read/write property whose value is a Boolean.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

Looks like the try line saved it from bugging out, thank you.