How to place sketched symbol and assign layer and leader style

How to place sketched symbol and assign layer and leader style

mcarlton71
Enthusiast Enthusiast
800 Views
2 Replies
Message 1 of 3

How to place sketched symbol and assign layer and leader style

mcarlton71
Enthusiast
Enthusiast

I have ilogic code that will place sketched symbols in view windows at a defined position.  I am now trying to customize this for a specific sketched symbol that I want to assign a different "layer" and "leader style" to.  Cant seem to find a way to do this within the code i am using.  

 

from the "insert sketched symbol" menu, once I select my symbol I can then manually select the layer and style before dropping in my view. OR I have to do this task after the symbol is placed.   any assistance on what i might add to do this.  i have tried defining my oLayer and oLeader to the ones I want to use from the styles manager but cant figure out where to then use them when the sketched symbol is added.  thanks.

 

'AUTO TAG
'iLogic - select view and insert AUTO TAG

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "'View On' View Label"
Dim oSymDef As SketchedSymbolDefinition : oSymDef = oDoc.SketchedSymbolDefinitions.Item(“AUTO TAG")


'This is the selected view
Dim oView As DrawingView: oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select View To Place Symbol:")

'This takes the label items of the selected view
'And adds it To an array that will link To the prompted entry
Dim sPromptStrings(4) As String
sPromptStrings(0) = "String 0"
sPromptStrings(1) = "String 1"
sPromptStrings(2) = "String 2"
sPromptStrings(3) = "String 3"
sPromptStrings(4) = "String 4"


'This is the position for the sketched symbol under the selected view'
Dim oPosition As Point2d: oPosition = oView.Center
'oPosition.Y = oPosition.Y - (oView.Height/1.90625)
'oPosition.X = oPosition.X - (oView.Width / 500)
oPosition.Y = oPosition.Y + (oView.Height/6)
oPosition.X = oPosition.X + (oView.Width/5)

'This inserts the sketched symbol and fills in the prompted entry.
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)
'This will run promp
 

 

0 Likes
Accepted solutions (1)
801 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Just like the secondary manual process you mentioned, where you place the symbol, then set its Layer and Leader Style afterwards.  You can do the same process in your code.  At the end of the code you posted, where you have just created/placed the symbol and have set the value of your oSymbol variable, include a couple of lines like this:

oSymbol.Layer = oMyLayerObject
oSymbol.LeaderStyle = oMyLeaderStyleObject

...but of course, you must have first created those two variables (or other similar variables) used as Values here, and set their values.  How you find/get that Layer and LeaderStyle are another matter.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

mcarlton71
Enthusiast
Enthusiast
Thanks, this was exactly what i was looking for . with a little trial and error i was able to get the results i needed!!
0 Likes