Creating Custom Leader Text

Creating Custom Leader Text

pedcarson
Enthusiast Enthusiast
2,834 Views
10 Replies
Message 1 of 11

Creating Custom Leader Text

pedcarson
Enthusiast
Enthusiast

So I'd like to ideally add a custom leader button so when I attach it to a part, instead of a blank text input box coming up, it already has the following lines:

 

DEVELOPMENT

QTY:

MAT'L:

PART NO:

 

I suppose it's asking too much to have part no. and material etc linked to the actual part but at least having this blank template would save some time. Is something like this possible?

0 Likes
2,835 Views
10 Replies
Replies (10)
Message 2 of 11

kennyj
Collaborator
Collaborator

Hello Pedcarson!

 

Yes this is possible.

 

The fast way (I think) is to make a sketch symbol.  Start your sketch, place your text and either make the text Prompt and/or link the text to your iProperties (or custom iProperties) to auto fill (this is what I'd do).

 

Then, under Styles Editor, Balloon Style change your default balloon shape to your custom symbol made above. (Or if you use the default balloons also, just create a new second Balloon Style).  Then when you place balloons, the information shown will be the custom symbol's info.  Balloon is already set up to pull whatever info you choose from the individual parts' iProperties. If you use the default Balloon place the balloon, right click on it and edit to your custom symbol to have it switch over.

 

Taking it a step further, you could then create your custom button of the new balloon style.

 

Hope this helps,

 

Kenny

 

 

 

 

 

 

0 Likes
Message 3 of 11

pedcarson
Enthusiast
Enthusiast

When you say start your sketch, do you mean start a new sketch and place anywhere on the sheet?

 

I'm in the annotate tab now and see Insert Sketch symbol but its asking me to search for Local or Symbol Libraries. It sounds like a good method just need to get started!

0 Likes
Message 4 of 11

Ktomberlin
Advocate
Advocate

Right from the programming help they have an example for this.  No real need to make a symbol, but that would also work but then you'd have symbol in the resources when you don't need too.  You'll probably have to adjust the points to get the desired result.

 

Add new leader note API Sample (modified for pedcarson's text)

Public Sub Main()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument

    ' Set a reference to the active sheet.
    Dim oActiveSheet As Sheet
    oActiveSheet = oDrawDoc.ActiveSheet

    ' Set a reference to the drawing curve segment.
    ' This assumes that a drawing curve is selected.
    Dim oDrawingCurveSegment As DrawingCurveSegment
    oDrawingCurveSegment = oDrawDoc.SelectSet.Item(1)

    ' Set a reference to the drawing curve.
    Dim oDrawingCurve As DrawingCurve
    oDrawingCurve = oDrawingCurveSegment.Parent

    ' Get the mid point of the selected curve
    ' assuming that the selected curve is linear
    Dim oMidPoint As Point2d
    oMidPoint = oDrawingCurve.MidPoint

    ' Set a reference to the TransientGeometry object.
    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    Dim oLeaderPoints As ObjectCollection
    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

    ' Create a few leader points.
    Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10))
    Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5))

    ' Create an intent and add to the leader points collection.
    ' This is the geometry that the leader text will attach to.
    Dim oGeometryIntent As GeometryIntent
    oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)

    Call oLeaderPoints.Add(oGeometryIntent)

    ' Create text with simple string as input. Since this doesn't use
    ' any text overrides, it will default to the active text style.
    Dim sText As String
    'sText = "API Leader Note"
    sText = "DEVELOPMENT" & vbCrLf & "QTY:" & vbCrLf & "MAT'L:" & vbCrLf & "PART NO:"

    Dim oLeaderNote As LeaderNote
    oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText)

    ' Insert a node.
    Dim oFirstNode As LeaderNode
    oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes.Item(1)

    Dim oSecondNode As LeaderNode
    oSecondNode = oFirstNode.ChildNodes.Item(1)

    Call oFirstNode.InsertNode(oSecondNode, oTG.CreatePoint2d(oMidPoint.X + 5, oMidPoint.Y + 5))
End Sub

 

Message 5 of 11

pedcarson
Enthusiast
Enthusiast

Am I adding this code as new in the VBA editor? 

0 Likes
Message 6 of 11

Ktomberlin
Advocate
Advocate
no this code is in illogic, you'll have to look up in programming help if you want to do it in VBA. Bascially the only change is adding set to any line with an assignment of a variable. i.e.
Set oDrawDoc = ThisApplication.ActiveDocument
0 Likes
Message 7 of 11

pedcarson
Enthusiast
Enthusiast

iLogic in Manage Tab then Add form or Add rule?

 

Maybe I need to look up how to use iLogic?

0 Likes
Message 8 of 11

kennyj
Collaborator
Collaborator

Good morning, pedcarson.

 

In the drawing, under the Browser's "Sketch Symbols" folder, right click on the folder.  Choose "Define new symbol".

 

This will open the sketch.

 

Under Sketch, choose Text.

 

 

There is a blank pull down (below the font options).  This lets you choose if the iProperties of the part file or drawing file are used, etc.  The one to the right of it lets you choose the specific property.  Hit the "X" with the down arrow to place that option/text into the field.

 

Save (name your symbol).

 

Then to test, insert the symbol on a part to see if it populates.  Then place a balloon, and change rt click to edit it to use the custom shape (the symbol).  It should populate with the info needed.

 

Hope that helps!

 

Kenny

 

0 Likes
Message 9 of 11

pedcarson
Enthusiast
Enthusiast

That actually worked well for PART NUMBER. I could use this in a leader and it would recognize what its pointing to and change the part number. It does not work for other parameters though like Thickness and Material. Those don't seem to change depending on what the leader is pointed to.

 

The reason I want to do this is so I can quickly copy and paste leaders with the parameters that update according to what they are pointing to. Half way there though!

0 Likes
Message 10 of 11

kennyj
Collaborator
Collaborator

Hi Pedcarson,

 

In the format Text box, you have a lot of pre-made properties that will automatically update.  This is why I recommended making a sketch block for what you are doing.

 

Place text, then change to Properties - Model.  See the attached image; Material is a default option.

 

As for thickness, this can be added as a custom iProperty to the part, which would then be available to add as an automated part.  If you are using sheet metal, then there is already a sheet metal option as well.

 

 

Also, Part Number is only one of a lot of options under the Balloon command; you can pull any iProperty in.  Look again at the style editor for the Balloon. 

 

So again, make a sketch block with (3) separate text bodies, each one linked to the property you want (Part Name, Material, Custom Thickness).

 

Then change your Balloon to reference this sketch block.

 

Best regards,

 

Kenny

Message 11 of 11

kennyj
Collaborator
Collaborator

Pedcarson,

 

Attached image is an example of what your sketch block would look like and how it would perform.

 

The left side is each of the text items, using the properties.  These can all be in one text box or separate like I've shown them. 


I placed the "Thickness" as a prompt; when placing the symbol it will ask the user to input the thickness.  You can make a custom property and link it like the part name and material are.

 

Then image on the right is the symbol inserted directly into the drawing, on the part.  Once placed, pull the symbol away to get the leader.  Personally, I don't like that extra step.  So from here, I go to Balloon and change Balloon to use my symbol block.  Same results.

 

Hope that helps,

 

Kenny