QLeader modification

Discussion in 'AutoCAD' started by Robert J., May 12, 2004.

  1. Robert J.

    Robert J. Guest

    Hello,
    I need to accomplish a lisp function, and am a little clueless of how to do
    it. I use the qleader command very frequently. Most of the time, I have two
    leaders that have the same text attached to them. I want to be able to run
    qleader (or something similar), pick two spots, and then the ends of the
    leaders both go to the finishing location (where the text would go)... Is
    there something like this out there, or would this be a pretty painless lisp
    routine that I could attach to a toolbar icon??

    TIA

    -Robert J.
     
    Robert J., May 12, 2004
    #1
  2. Robert J.

    Casey Guest

    I've looked a little and haven't found one. A workaround I use is:

    Draw first qleader and input text.
    Draw 2nd qleader and input at least one text character.
    Erase 2nd qleader's text
    Use express tools 'qlattach' to attach the leader to the first text.

    Long and drawn out so I don't use it very often, but it works.
     
    Casey, May 13, 2004
    #2
  3. Robert J.

    Joshua Tapp Guest

    You can also skip the text on the second leader by using the regular leader
    command.

    Sounds like at the least this could be automated.
     
    Joshua Tapp, May 13, 2004
    #3
  4. Robert J.

    Casey Guest

    When I skip the text on the second leader and then use the regular leader,
    when i 'qlattach' it underlines the text with the second leader. My qleader
    (the first one) is middle left attachment. Am I missing something? Any
    suggestions would be appreciated.


    Thanks,

    Casey
     
    Casey, May 13, 2004
    #4
  5. Robert J.

    TCEBob Guest

    Try this:

    (defun c:lem ( /p1 p2) ;quick leader multiple arrows
    (setq p1 (getpoint "\nArrow point: ")
    p2 (getpoint p1 "\nEnd point: ")
    )
    (command "leader" p1 p2 "" " " "")
    (command "change" "l" "" "p" "lt" "continuous" "")
    (while
    (setq p1 (getpoint "\nNext Arrow point: "))
    (command "leader" p1 p2 "" "" "n")
    (command "change" "l" "" "p" "lt" "continuous" "")
    )
    (princ)
    )

    rs
     
    TCEBob, May 13, 2004
    #5
  6. Robert J.

    Robert J. Guest

    I can't get it to work. I get the "too few arguments" error.
    ????
     
    Robert J., May 13, 2004
    #6
  7. Robert J.

    Phil Guest

    I have two buttons one with qleader and one with qleader that cancels
    out leaving a simple arrow.

    but if you want the double in a button you can try it in a simple diesel
    macro.

    I don't have my acad here at home to experiment or test it so you most
    likely will have to tweak it to make it work. There's no spaces so
    watch the copy paste. Just plug it into a custom button.

    ^Cid;$m=id;\$m=id;\$m=qleader;$(getvar,lastpoint);""$(getvar,lastpoint)"
    ";^cqleader;"$(getvar,lastpoint);""$(getvar,lastpoint)""";;;
     
    Phil, May 14, 2004
    #7
  8. Robert J.

    Phil Guest

    forgot a prompt

    ^Cid\;$m=id;\$m=id;\$m=qleader;$(getvar,lastpoint);""$(getvar,lastpoint)
    "";^cqleader;"$(getvar,lastpoint);""$(getvar,lastpoint)""";;;
     
    Phil, May 14, 2004
    #8
  9. Robert J.

    Kiwi Russ Guest

    Instead of : (defun c:lem ( /p1 p2)
    try (defun c:lem ( / p1 p2)
     
    Kiwi Russ, May 14, 2004
    #9
  10. Robert J.

    Casey Guest

    I get it to work, but it doesn't address the original post. When you draw a
    qleader with text, the text is attached to the leader. (ie when you move the
    text, the leader tail goes with it.) The objective it to have multiple
    leader lines that are 'attached' to a single mtext object, so when you move
    the text object, the leader tails (all of them) move with it.

    Unless I'm missing something, the posted routine doesn't do this.

    Casey
     
    Casey, May 14, 2004
    #10
  11. Robert J.

    TCEBob Guest

    Sorry, Casey, I guess I misread the original. You want one text assigned
    to 2 leaders? Hmm.

    rs
     
    TCEBob, May 15, 2004
    #11
  12. Robert J.

    Casey Guest

    I know, quite the connundrum.


     
    Casey, May 15, 2004
    #12
  13. Robert J.

    ECCAD Guest

    Robert,
    Since the MTEXT is attached to the Leader (one only), with an
    acad_reactors..and uses dxf 202, dxf 330 to identify the
    Leader entity..I think you are out of luck in trying to attach yet
    a (2nd) leader to the reactor..
    So, I came up with a little lisp that might get you closer to the
    goal.



    ;; Routine to move (2) leader endpoints
    ;; when moving MTEXT attached to (1) of the leaders.
    ;;
    (defun c:ml ()
    (setq old_osmode (getvar "OSMODE"))
    (prompt "\nPick the Leader MTEXT to move:")
    (setq ss (ssget))
    (if ss
    (progn
    (setq PM (getvar "LASTPOINT"))
    (setvar "OSMODE" 1); end point
    (setq P1 (getpoint "\nPick Leader 2 EndPoint to move:"))
    (setq W1 (list (- (car P1) 0.0625)(+ (cadr P1) 0.0625)))
    (setq W2 (list (+ (car P1) 0.0625)(- (cadr P1) 0.0625)))
    (prompt "\nPick a new location for the MTEXT:")
    (command "_move" ss "" PM pause)
    (setq P2 (getvar "LASTPOINT"))
    (setq obj nil)
    (setq obj (ssget "_c" W1 W2))
    (if (/= obj nil)
    (command "_stretch" "_c" W1 W2 "_w" W1 W2 "" P1 P2); stretch / move 2nd Leader
    ); end if
    ); end progn
    ); end if
    (setvar "OSMODE" old_osmode)
    (princ)
    ); end function
    (prompt "\nType ML to move Leaders..")
    (princ); silent load
     
    ECCAD, May 15, 2004
    #13
  14. Robert J.

    Jeff Mishler Guest

    Here's a little lisp to try in place of the qleader command. Command name is
    2ldr. If you run this more than once using the same mtext object that object
    will have (2 times the number of times run) leaders all attached to it.

    No error checking of any kind is provided in this routine. I am posting this
    solely for the purpose of demonstrating what can be done with leader & Mtext
    objects. Modify to suit, the basics for just selecting mtext & the leaders
    to attach are all here.

    Have fun,
    Jeff

    (defun c:2ldr (/ coords1 coords2 ldr1 ldr2 p1 p2 p3 space txt)
    (vl-load-com)
    (if
    (and (setq p1 (getpoint "\nSelect common leader point: "))
    (setq p2 (getpoint p1 "\nSelect first leader endpoint: "))
    (setq p3 (getpoint p1 "\nSelect second leader endpoint: "))
    (setq txt (car (entsel "\nSelect MiddleLeft or MiddleRight Justified Mtext
    object: ")))
    (setq txt (vlax-ename->vla-object txt))
    )
    (progn
    (setq coords1 (append p2 p1)
    coords2 (append p3 p1)
    )
    (setq space (vla-objectidtoobject
    (vla-get-activedocument
    (vlax-get-acad-object))
    (vla-get-ownerid txt)))
    (setq ldr1 (vlax-invoke space "addleader" coords1 txt
    acLineWithArrow))
    (setq ldr2 (vlax-invoke space "addleader" coords2 txt
    acLineWithArrow))
    (vla-put-verticaltextposition ldr1 0)
    (vla-put-verticaltextposition ldr2 0)
    )
    )
    (princ)
    )
     
    Jeff Mishler, May 15, 2004
    #14
  15. Robert J.

    jmckinnon Guest

    This is my simple solution:
    A new leader with no text.
    _LEADER;\\;;N;
    Simply snap to leader line intersection of first leader
     
    jmckinnon, May 15, 2004
    #15
  16. Robert J.

    TCEBob Guest

    Yeah, that's what I provided back a few posts. Not what he's looking
    for. He wants a piece of text associated with two leaders, say on
    different sides.

    rs
     
    TCEBob, May 15, 2004
    #16
  17. Robert J.

    TCEBob Guest

    Jeff, I have seen this "vlax-invoke-method" thing in help. I am in need
    of a fundamental guidebook to this type of programming. Help, for
    example, invokes a "draw circle" method. Where do these "methods" live
    and how can one get a list of them? I don't want to impose on your time
    to personally tutor me but where does one go to learn about this stuff?
    What's the difference between a "method" and a function?

    rs
     
    TCEBob, May 15, 2004
    #17
  18. Robert J.

    Jeff Mishler Guest

    Hi Bob,
    All of the methods and properties that can be used with vla-objects are
    described in the ActiveX & VBA Reference help file. It takes a little
    bit of playing around with the different ways of doing things with the
    ActiveX stuff, but in the end it is so much easier to work with than
    entmake/entmod.
    For the circle that is shown in the Lisp help for "vlax-invoke-method",
    there are actually two ways of creating a circle. The first way is as
    shown in the help:
    (setq circCenter (vlax-3d-point '(3.0 3.0 0.0)))
    (setq mycircle (vlax-invoke-method mspace 'AddCircle circCenter 3.0))

    What the help doesn't tell you is that 'mspace' is a variable that needs
    to be set to either Modelspace, Paperspace or a Block Reference.
    So they should have included this line:
    (setq mspace (vlax-get (vlax-get (vlax-get-acad-object) 'Activedocument)
    'ModelSpace))

    The second way is similar, but different:
    (setq mycircle (vlax-invoke mspace "AddCircle" '(3.0 3.0 0.0) 3.0))
    Note that the centerpoint doesn't need to be converted to a variant
    first this way.

    In both you must provide the object that will be the "owner" of the new
    circle (Modelspace in this case), the center point and the radius.

    There is actually a third way, but Tony T. and John U. have advised
    against using it for various reasons:
    (setq circCenter (vlax-3d-point '(3.0 3.0 0.0)))
    (setq mycircle (vla-AddCircle mspace circCenter 3.0))

    So between the ActiveX & VBA Reference, (vlax-dump-object obj t), and
    this newsgroup you can usually figure out which way is best for you.

    Also, there's more than one way to get the properties of an object:
    (vlax-get-property obj 'Layer)
    (vla-get-layer obj)
    Both will get the object's layer name.

    If you want more guidance, just ask and I, or someone, will do our best
    to nudge you along.

    Good Luck,
    Jeff
     
    Jeff Mishler, May 16, 2004
    #18
  19. Robert J.

    TCEBob Guest

    Thanks. I'll chew on that for a while. So "methods" are available in
    ActiveX and VBA and the Vlax-invoke-method taps into that resource. (?)
    Cover me, I'm goin' in.

    rs
     
    TCEBob, May 16, 2004
    #19
  20. Not exactly what Casey is looking for, but if there turns out not to be a
    solution that does that:
    If, when you need to move the text, you are willing to do it with Stretch,
    and you include the tail ends of the leaders in the Stretch Crossing
    selection window, then both (or all three, or all eighteen) leaders will
    adjust with the text, whether they all come up to it at one place, or from
    different sides, or from every which way.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, May 16, 2004
    #20
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.