Sketched symbols...still

Sketched symbols...still

Anonymous
Not applicable
320 Views
1 Reply
Message 1 of 2

Sketched symbols...still

Anonymous
Not applicable
The following code will find the sketched symbol called "hex" and call up the insert dialog for sketched symbols with "hex" highlighted. How do I modify this code to bypass the dialog and just start the insert?




Public Sub InsertSymbol()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

' Get the sketched symbol named "?".
Dim sSketchSymbolName As String
sSketchSymbolName = "Hex"

Dim oNode As BrowserNode
Set oNode = GetSymbolNode(oDrawDoc.BrowserPanes.ActivePane.TopNode, sSketchSymbolName)

' Select the symbol.
Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet
oSelectSet.Clear
oNode.DoSelect

' Execute the Insert Drawing Sketch Symbol command.
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSymbolsCmd").Execute
End Sub

Private Function GetSymbolNode(ByVal TopNode As BrowserNode, ByVal SymbolName As String) As BrowserNode
' Iterate through the children of the input node.
Dim oNode As BrowserNode
For Each oNode In TopNode.BrowserNodes
' Look for the "Sketched Symbols node".
If oNode.BrowserNodeDefinition.Label = "Sketched Symbols" Then
' Find the specified node.
Dim oSymbolNode As BrowserNode
For Each oSymbolNode In oNode.BrowserNodes
If UCase(oSymbolNode.BrowserNodeDefinition.Label) = UCase(SymbolName) Then
' Assign the node as the output value and exit the function.
Set GetSymbolNode = oSymbolNode
Exit Function
End If
Next
End If

' Check if the node has been found and exit the function.
If Not GetSymbolNode Is Nothing Then
Exit Function
Else
' Recursively call this function to traverse the browser tree.
Set GetSymbolNode = GetSymbolNode(oNode, SymbolName)
End If
Next
End Function
0 Likes
321 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
I've modified and simplified the macro below. The control definition that I
used below by-passes the dialog and creates a "static" symbol (can't be
rotated and scaled). You can edit the symbol to make it non-static after the
creation (either thru the UI or the API). Also note that I'm directly
selecting the symbol definition rather than the browser node.

Sanjay-

Public Sub InsertSymbol()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSymbolDef As SketchedSymbolDefinition
Set oSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("Hex")

' Select the symbol.
oDrawDoc.SelectSet.Clear
oDrawDoc.SelectSet.Select oSymbolDef

' Execute the Insert Drawing Sketch Symbol command.
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingUserDefinedSymbolsQuickCtxCmd").Execute

End Sub


wrote in message news:5733640@discussion.autodesk.com...
The following code will find the sketched symbol called "hex" and call up
the insert dialog for sketched symbols with "hex" highlighted. How do I
modify this code to bypass the dialog and just start the insert?




Public Sub InsertSymbol()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

' Get the sketched symbol named "?".
Dim sSketchSymbolName As String
sSketchSymbolName = "Hex"

Dim oNode As BrowserNode
Set oNode = GetSymbolNode(oDrawDoc.BrowserPanes.ActivePane.TopNode,
sSketchSymbolName)

' Select the symbol.
Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet
oSelectSet.Clear
oNode.DoSelect

' Execute the Insert Drawing Sketch Symbol command.
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSymbolsCmd").Execute
End Sub

Private Function GetSymbolNode(ByVal TopNode As BrowserNode, ByVal
SymbolName As String) As BrowserNode
' Iterate through the children of the input node.
Dim oNode As BrowserNode
For Each oNode In TopNode.BrowserNodes
' Look for the "Sketched Symbols node".
If oNode.BrowserNodeDefinition.Label = "Sketched Symbols" Then
' Find the specified node.
Dim oSymbolNode As BrowserNode
For Each oSymbolNode In oNode.BrowserNodes
If UCase(oSymbolNode.BrowserNodeDefinition.Label) = UCase(SymbolName) Then
' Assign the node as the output value and exit the function.
Set GetSymbolNode = oSymbolNode
Exit Function
End If
Next
End If

' Check if the node has been found and exit the function.
If Not GetSymbolNode Is Nothing Then
Exit Function
Else
' Recursively call this function to traverse the browser tree.
Set GetSymbolNode = GetSymbolNode(oNode, SymbolName)
End If
Next
End Function
0 Likes