Leader & Annotation

Discussion in 'AutoCAD' started by Kiwi Russ, Apr 30, 2004.

  1. Kiwi Russ

    Kiwi Russ Guest

    Hi
    I'm trying to make a (supposedly) simple lisp where a leader is drawn
    via 2 points the last line is horizontal. I would like to use "mtext" to
    place my own text rather than the leader text as it has its own annoying
    characteristics. Of course if I use my own mtext that's added onto the
    leader, then it has to know what justification to use - but I reckon I can
    do that by what direction the arrow goes.

    My wheels are spinning on:

    1) I can not figure out how to find the point where the insertion point for
    the text might be?

    2) Why is my leader "exploded"? I know dim1 has something to do with this
    but the help is a bit lame on explaining how this works.

    3) as I said my lisp will need to know what direction the leader goes so it
    can determine the text justification - any thoughts about how I can do this?

    Here is my attempt so far........

    (defun C:LE ()
    (setvar "CMDECHO" 1)

    (command "dim1" ".LEADER" pause pause "" "")
    (princ)
    );defun

    Thank you
    Russ
     
    Kiwi Russ, Apr 30, 2004
    #1
  2. Kiwi Russ

    urugx Guest

    Try this:

    1) draw a leader with Mtext (1 line only).
    2) get DXF properties of leader and mtext
    3) For a 2 points leader, there will be 3
    DXF 10 association list. IMO, the first one is
    the end of the arrowhead (pt1), the second one
    is the start of the short horizontal line (pt2) and
    the third one is the end this line (call this pt3).
    4) For the Mtext, the DXF10 is the insert point of
    the text (call this pt4).
    5) The distance between pt2/pt3 and the gap between
    pt3/pt4 are both govern by setvars.

    Maybe this will help you in what you're trying to do.
    IMHO, I'll draw it first., examine the points against the
    entity association list before I even try to write a line
    of code.
     
    urugx, Apr 30, 2004
    #2
  3. You don't need the association list. You can just make your Mtext
    middle-left or middle-right justified, at a point offset to the side of the
    tail end of the leader, calculating the direction by comparing the two
    leader points.

    Try something like this, in auto-repeat macro format with explanatory
    interpolated lines to be removed (untested):

    *^C^C-LAYER S <your-notes-layer> (setq ortho (getvar "ORTHOMODE")) ORTHO
    OFF +
    [sets layer, checks Ortho and turns it off, assuming you don't want the
    leader orthogonal]
    LEADER (setq head (getpoint "Arrow head: ")) \(setq tail (getpoint "Tail
    end: ")) \;;N +
    [makes leader, saving the two points you give it, and bypassing the
    annotation parts at the end]
    ORTHOMODE !ortho +
    [resets Ortho as it was]
    (if (> (- (car tail) (car head)) 0) (setq justif "ML" gapdirection (getvar
    "DIMSCALE")) +
    (setq justif "MR" gapdirection (- (getvar "DIMSCALE")))) +
    [compares x coordinates of head and tail points, and sets Mtext
    justification and direction of offset for Mtext insertion point,
    accordingly]
    (setq textpoint (list (+ (car tail) (* (getvar "DIMGAP") gapdirection))
    (cadr tail)) +
    [sets insertion point for Mtext, horizontally off tail point in the
    appropriate direction]
    (command "MTEXT" textpoint "J" justif)

    That should leave you at the point where it asks for a text box width. Pick
    a point straight to the right or left (as appropriate), not higher or lower,
    and it should center the Mtext (however many lines it comes to) vertically
    around the tail end of the leader. If you have a "standard" width for the
    text box, you can have it feed that in, for example if it's 3":
    ....(command "MTEXT" textpoint "J" justif) +
    (list (+ (car (getvar "LASTPOINT")) (* 3.0 gapdirection)) (cadr tail))

    That should leave you with the Mtext dialog box to type in the contents.

    I you'd rather have it put the Mtext so the leader tail aligns with the top
    line instead of the middle, you can substitute TR and TL for the MR and ML,
    and replace the (cadr tail) in the insertion point calculation with a y
    coordinate that adds half the text height to that; you could also have the
    tail align with the bottom line when the Mtext is left of the leader, by (if
    the gapdirection is negative) setting the justification to BR and
    subtracting half the text height for the y coordinate of the insertion
    point. Etc., etc.

    Again, use a plain Leader, not the leader sub-command in DIM or DIM1, which
    comes in "exploded."

    Kent Cooper, AIA


    this?
     
    Kent Cooper, AIA, Apr 30, 2004
    #3
  4. Kiwi Russ

    Kiwi Russ Guest

    Also one other problem:
    Why doesn't the layer set back to the previous layer when I use
    (setvar "CLAYER" OldLay) ?

    thanks if you can help.
     
    Kiwi Russ, May 1, 2004
    #4
  5. For Pline with arrow change -
    (command "pline" head tail Endpt "")
    (setvar "OSMODE" 0)
    (command "._Pline" head "_Width" "0.0" #ArwBase
    (polar head ang #ArwLen) "_Width" "0.0" "0.0" "")
    To -
    ;; (command "pline" head tail Endpt "") ;;remove this line
    (setvar "OSMODE" 0)
    (command "._Pline" head "_Width" "0.0" #ArwBase
    (polar head ang #ArwLen) "_Width" "0.0" "0.0" tail Endpt "")

    Note you might want to change -
    tail (getpoint "Tail end: ")
    To -
    tail (getpoint head "Tail end: ")
    This will show where the leader is going to start from using rubberbanding

    Change -
    (command ".color" "bylayer" "" )
    To -
    (command ".color" "bylayer") ;extra "" not necessary in my version
    of AutoCAD

    Move -
    (initdia)
    To just before (command "Mtext".....
    Current location caused Layer dialog box to open and not Mtext dialog box.
     
    Alan Henderson @ A'cad Solutions, May 1, 2004
    #5
  6. Kiwi Russ

    Kiwi Russ Guest

    Alan
    many Thanks!!! great that has solved a heap of problems (plus the
    rubber banding one that I forgot to ask about).
    I'm still struggling on the mtext line though. I don't want to pick points
    and I want to go into the dialog straight away and have the text centred at
    the end of the leader. Not sure how to fix it. Anyone have any ideas??
    thanks Russ
     
    Kiwi Russ, May 1, 2004
    #6
  7. Kiwi Russ

    Walt Engle Guest

    Would you like a leader with text where the leader can be on the right or left?
    However, my lsp is old and it uses dtext.
     
    Walt Engle, May 2, 2004
    #7
  8. It looks like the arrow and the pline are separate entities for the simple
    reason that you're making them as separate entities. Am I missing
    something?

    I can't fathom why you appear to be "building" a Leader using polylines,
    instead of using an actual Leader. It's possible to make it LOOK like a
    leader with changing width, but even if you make it one entity that way, it
    won't function like a leader (i.e. if you stretch the tail end, the arrow
    head won't rotate accordingly). There's no benefit over the Dim sub-command
    leader, and it's much more complicated to make.

    Kent Cooper, AIA

    ...
     
    Kent Cooper, AIA, May 3, 2004
    #8
  9. Could it be the unneeded spaces in there? Are the other system variables
    that you're setting (with extra spaces) working properly?

    Kent Cooper, AIA

    ...
     
    Kent Cooper, AIA, May 3, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.