Segmented Leader with MTEXT

Discussion in 'AutoCAD' started by MiD-AwE, Feb 1, 2005.

  1. MiD-AwE

    MiD-AwE Guest

    Hey all,

    I'm working on Leader that will allow me to designate, by mouse clicks, several segments and finally assign MTEXT to the end. Currently I just do the first part like this:

    (DEFUN C:IRI ()
    (COMMAND "ORTHO" "OFF" "OSNAP" "NEA" "LAYER" "S" "DIM" "" "DIMSTYLE" "R" "LAYOUT")
    (COMMAND "DIMSTYLE" "R" "LAYOUT" "")
    (COMMAND "LEADER" PAUSE PAUSE PAUSE PAUSE "6\" RISER" "")
    (COMMAND "OSNAP" "INTERSECT" "INSERT" "ARO" "" "")
    (COMMAND "OSNAP" "NONE")
    )

    but this has obvious limitations. Here is the clincher; I need to allow any number of selection points or segments and I need to add the arrow to each one with the correct alignment.

    In the ".mns" file I tried this:

    [2 Steps]^C^COSNAP NEA Ortho Off -Layer S Dim;;-Dimstyle R Layout Leader \\;;N;^C^COSNAP INT LEADER \\; 6" RISER;;

    but it suffers some of the same limitations. Any help or guidance is greatly appreciated.
     
    MiD-AwE, Feb 1, 2005
    #1
  2. MiD-AwE

    BillZ Guest

    Do you mean something like this?

    Code:
    (while (setq pt (getpoint "\nPick points for LEADER: "))(setq lt (cons
    pt lt)))
    (COMMAND "LEADER")
    (foreach n lt
    (command n)
    )
    (command "A" "this
    is a test" "")
    


    Bill
     
    BillZ, Feb 1, 2005
    #2
  3. MiD-AwE

    MiD-AwE Guest

    Not really. While the ability to select multiple segment start and stop points is exactly what I was looking for I also need to be able to add the arrow at the same points all properly aligned. Also, I noticed that if I tried to reuse your command a second time then it replicated the previous points then included the new points as well. As this maybe useful for someone, it only created a big mess for me. I'll continue to study it in case I manage to learn of a method that will work for me. Thanks for your help, but I still need help.
     
    MiD-AwE, Feb 1, 2005
    #3
  4. MiD-AwE

    T.Willey Guest

    Here is the leader part based off what BillZ posted.

    Tim

    (defun c:drawleader (/ pt pt2 ptlist cnt1)

    (if (setq pt (getpoint "\n Select start point of leader: "))
    (progn
    (while pt
    (setq ptlist (cons pt ptlist))
    (if (setq pt2 (getpoint pt "\n Select next point: "))
    (grdraw pt pt2 -1)
    )
    (setq pt pt2)
    )
    (setq ptlist (reverse ptlist))
    (command "leader")
    (foreach item ptlist
    (command item)
    )
    (command "" "" "n")
    (command "leader" (last ptlist) (nth (- (length ptlist) 2) ptlist) "" "" "n")
    (command "redraw")
    )
    )
    (princ)
    )
     
    T.Willey, Feb 1, 2005
    #4
  5. MiD-AwE

    MiD-AwE Guest

    Thank you, this is closer to what I'm trying to do, but for some reason the second leader is pointing the wrong direction. Or, I'm picking points in the wrong order. Either case the arrows point in opposite directions and I need them to point in them to point in the direction I pick from star to finish.

    I saw the use of reverse in the command and I looked it up, but I do not understand how to use it myself, therefore I can't remove it. It may need to be there and may have nothing to do with my issue but I am not sure.

    I might not have explained how the command should work well enough. I would like it to work by clicking the nearest point on my first riser then clicking the second riser then clicking the point where my text should be. (does not need to be MTEXT since I fill it in within the command its self.) But all arrows need to point toward the risers and away from the text.

    Thanks again.
     
    MiD-AwE, Feb 1, 2005
    #5
  6. MiD-AwE

    T.Willey Guest

    The arrow heading is easy. Just change this line
    (command "leader" (last ptlist) (nth (- (length ptlist) 2) ptlist) "" "" "n")

    to

    (command "leader" (nth (- (length ptlist) 2) ptlist) (last ptlist) "" "" "n")

    So now it will drawing a leader from the second to last point to the last point.

    The part about the text, um I guess you could select one point then start the dtext command from that point, but what about the text height, and justification? You may need to explain more about the text, or maybe try some stuff, and if it doesn't work then you can post what you have, and tell us what you want to happen.

    Tim
     
    T.Willey, Feb 1, 2005
    #6
  7. MiD-AwE

    MiD-AwE Guest

    Thanks, that was so fast. . .

    I'll do as you said and experiment on my own for a while.

    I would like to explain some of my thoughts on how I'd like to do it but I lack the "know how".

    Is it possible to capture the mouse click points into variables at the same time while drawing a spline then insert my "ARO.dwg" block at those points and have them align themselves to the spline by order of mouse clicks (from first to second, from second to third, etc.)? This of course, is leaving the text issue for another day, but I'd probably like to use MTEXT just so that I can use the QLATTACH command to some how join it all (not sure if that can be done either).

    Your help is much appreciated.
     
    MiD-AwE, Feb 1, 2005
    #7
  8. MiD-AwE

    T.Willey Guest

    You can, but they don't come out witht he right rotation. I don't know enough about splines to know what is the correct way to get the angle. Here is a test code that will show you want I mean (make sure your osmode is 0 when using). Sorry I don't have more time to help you, but maybe someone who knows more about splines can help.

    Tim

    (defun c:drawspline (/ pt pt2 ptlist cnt1)

    (if (setq pt (getpoint "\n Select start point of spline: "))
    (progn
    (while pt
    (setq ptlist (cons pt ptlist))
    (if (setq pt2 (getpoint pt "\n Select next point: "))
    (grdraw pt pt2 -1)
    )
    (setq pt pt2)
    )
    (setq ptlist (reverse ptlist))
    (command "_.spline")
    (foreach item ptlist
    (command item)
    )
    (command "" "" "")
    (setq cnt1 0)
    (while (/= cnt1 (length ptlist))
    (command "_.insert" "ARO" (nth cnt1 ptlist) "" "" (nth (1+ cnt1) ptlist))
    (setq cnt1 (1+ cnt1))
    )
    (command "redraw")
    )
    )
    (princ)
    )
     
    T.Willey, Feb 2, 2005
    #8
  9. MiD-AwE

    MiD-AwE Guest

    Thanks :)

    Wow I think that works great. I have plenty to work with now. Maybe I'll see if I can do this with a polyline or a MLEADER but either way, thank you for your help.
     
    MiD-AwE, Feb 2, 2005
    #9
  10. MiD-AwE

    T.Willey Guest

    Try this one. I use a polyline with your blocks. After it inserts the blocks, it goes into the mtext command.

    Tim

    (defun c:FlowLine (/ pt pt2 ptlist cnt1 opw oosm ActDoc)

    (vl-load-com)
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-StartUndoMark ActDoc)
    (setq opw (getvar "plinewid"))
    (setq oosm (getvar "osmode"))
    (setvar "plinewid" 0)
    (if (setq pt (getpoint "\n Select start point of polyline: "))
    (progn
    (while pt
    (setq ptlist (cons pt ptlist))
    (if (setq pt2 (getpoint pt "\n Select next point: "))
    (grdraw pt pt2 -1)
    )
    (setq pt pt2)
    )
    (setq ptlist (reverse ptlist))
    (command "_.pline")
    (foreach item ptlist
    (command item)
    )
    (command "" "" "")
    (setvar "osmode" 0)
    (setq cnt1 0)
    (while (/= cnt1 (length ptlist))
    (command "_.insert" "ARO" (nth cnt1 ptlist) "" "" (nth (1+ cnt1) ptlist))
    (setq cnt1 (1+ cnt1))
    )
    (command "redraw")
    (initdia)
    (command "_.mtext")
    (while (> (getvar "cmdactive") 1)
    (vl-catch-all-error-apply 'command 'pause)
    )
    )
    )
    (setvar "osmode" oosm)
    (setvar "plinewid" opw)
    (vla-EndUndoMark ActDoc)
    (princ)
    )
     
    T.Willey, Feb 2, 2005
    #10
  11. MiD-AwE

    MiD-AwE Guest

    It's so pretty, beautiful actually!
    "Brings a tear to me eye" ;)

    Thank you so much.
    You are fantastic!
     
    MiD-AwE, Feb 2, 2005
    #11
  12. MiD-AwE

    T.Willey Guest

    Glad it works for you.

    Tim
     
    T.Willey, Feb 2, 2005
    #12
  13. MiD-AwE

    ECCAD Guest

    Great work Tim,
    Now I got one for you too.
    I've been trying to get the (2nd) line to be Horizontal.
    Have a routine to setup the Qleader, style, etc.
    Includes a Dictionary setup for all the .dxf codes.
    Sets 71 to a 1, which is supposed to be 2nd Leader Line
    in Horizontal. But, it just ignores that and defaults to
    'Any Angle' - as seen in the Qleader-Settings Dialog.
    Where do I set it to Horizontal (without going into the Dialog)
    ????

    Could you shed a little light on that one ?

    Bob
     
    ECCAD, Feb 2, 2005
    #13
  14. MiD-AwE

    T.Willey Guest

    I don't really use qleader that much, but I remember seeing that you have to have a qleader within the drawing you are working in to modify the dictionary object. I did a little test and it seemed to work.

    (defun c:test (/ DictEnt)
    (command "_.qleader" (command))
    (setq DictEnt (dictsearch (namedobjdict) "AcadDim"))
    (entmod (subst (cons 71 1) (assoc 71 DictEnt) DictEnt))
    )

    Sorry I couldn't be more help.
    Tim
     
    T.Willey, Feb 2, 2005
    #14
  15. MiD-AwE

    ECCAD Guest

    Gary,
    Yep, that's the one. Does set dxf code 71 to a 1,
    but when placing the 'first' Qleader, doesn't (do)
    the 2nd line as Horizontal,,just leaves that setting
    as 'Any Angle' in the Qleader Settings dialog.
    Hmm.
    I'll give Tim's suggestion a whirl.

    Thanks.
    Bob
     
    ECCAD, Feb 2, 2005
    #15
  16. MiD-AwE

    ECCAD Guest

    Tim,
    You are Good.
    Works great.
    Now, why in the heck do we need to
    do the qleader - then cancel it :mad:
    Just to get a Dictionary entry in there ?
    Oh well, I guess I can live with it.

    Thanks a bunch.
    :)
    Bob
     
    ECCAD, Feb 2, 2005
    #16
  17. MiD-AwE

    T.Willey Guest

    Glad that helped. I know it kind of sucks to have to do it that way, but that is AutoCAD (sometimes).

    Tim
     
    T.Willey, Feb 2, 2005
    #17
  18. MiD-AwE

    Gary Fowler Guest

    Is this what you are talking about?

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;; Initialize the setting before using the QLEADER command
    ;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;Frank Whaley, Autodesk
    ;;;(dictsearch (namedobjdict) "AcadDim")
    (defun ARCH:QLSET ()
    (defun acet-ql-get (/ xr cod itm reply)
    (if (setq xr (dictsearch (namedobjdict) "AcadDim"))
    (progn (foreach
    cod '(3 40 60 61 62 63 64 65 66 67 68 69 70 71 72 170
    340)
    (if (setq itm (assoc cod xr))
    (setq reply (append reply (list itm)))))
    reply)
    '((3 . "")
    ;;user arrowhead block name (default="")
    (40 . 0.0)
    ;;40: default text width (default=0.0)
    (60 . 0)
    ;;annotation type (default=0)0=MText
    (61 . 0)
    ;;annotation reuse (default=0)0=none
    (62 . 1)
    ;;left attachment point (default=1)
    (63 . 3)
    ;;right attachment point (default=3)3=Middle of bottom line
    (64 . 0)
    ;;underline bottom line (default=0)NO
    (65 . 0)
    ;;use splined leader line (default=0)NO
    (66 . 0)
    ;;no limit on points (default=0)
    (67 . 3)
    ;;maximum number of points (default=3)
    (68 . 1)
    ;;prompt for MText width (word wrap) (default=1)
    (69 . 1)
    ;;always left justify (default=0)NO
    (70 . 0)
    ;;allowed angle, second segment (default=0)0=Any angle
    (71 . 1)
    ;;allowed angle, second segment (default=0)1=Horizontal
    (72 . 0)
    ;;frame text (default=0)NO
    (73 . 0)
    ;;
    (74 . 0)
    ;;
    (75 . 0)
    ;;
    (170 . 0)
    ;;active tab (default=0)0=Annotation
    )))
    ;;;
    (defun acet-ql-set (arg / cur prm)
    (setq cur (acet-ql-get))
    (while arg
    (setq prm (car arg)
    arg (cdr arg)
    cur (subst prm (assoc (car prm) cur) cur))
    (if (= 3 (car prm))
    (setvar "DIMLDRBLK" (cdr prm))))
    (dictremove (namedobjdict) "AcadDim")
    (setq cur (append '((0 . "XRECORD") (100 . "AcDbXrecord") (90 . 990106))
    cur))
    (dictadd (namedobjdict) "AcadDim" (entmakex cur))
    (acet-ql-get))
    ;;;
    (acet-ql-set (acet-ql-get))
    (princ))
     
    Gary Fowler, Feb 2, 2005
    #18
  19. MiD-AwE

    Gary Fowler Guest

    Plus previous code...
    This works for me...first line is nonhorizontal and second line is
    horizontal.

    (defun C:QLL ()
    ;;(ARCH:F_S-VAR)
    (setvar "cmdecho" 0)
    (setvar "orthomode" 0)
    (prompt "\n* Qleader : Please Pick leader start point *")
    ;;(ARCH:CUSTOM_LAYERS-ANNO)
    (setvar "DIMLDRBLK" ".")
    (ARCH:QLSET)
    (ALDR_SET)
    (command "qleader")
    (setvar "cmdecho" 1)
    (while (> (getvar "CMDACTIVE") 0) (command pause))
    ;;(ARCH:F_R-VAR)
    (princ))

    (defun ALDR_SET (/ ldrname)
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (progn (setvar "CMDECHO" 0)
    (setvar "DIMCLRT" 2)
    (setvar "DIMCLRD" 1)
    ;;(setvar "DIMBLK" ".")
    ;;(setvar "DIMBLK1" ".")
    ;;(setvar "DIMBLK2" ".")
    (setvar "DIMLDRBLK" ".")
    ;;(setvar "DIMLDRBLK" "")
    (cond ((= ARCH#UNIT "Ci") (setvar "DIMASZ" 0.2)) ;Arrow size
    ((= ARCH#UNIT "Mm") (setvar "DIMASZ" 5.08)) ;Arrow
    size
    ((= ARCH#UNIT "Cm") (setvar "DIMASZ" 0.508)) ;Arrow
    size
    ((= ARCH#UNIT "Ar") (setvar "DIMASZ" 0.2)) ;Arrow size
    ((= ARCH#UNIT "Me") (setvar "DIMASZ" 0.00508)) ;Arrow
    size
    ((= ARCH#UNIT "En") (setvar "DIMASZ" 0.2)) ;Arrow size
    )
    (setq DIMNAME (rtos (getvar "dimscale") 2 0))
    (setq ldrname (strcat "LDR-" DIMNAME))
    (cond ((/= (cdr (assoc 2 (tblsearch "dimstyle" ldrname)))
    ldrname)
    (command "dimstyle" "S" ldrname))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" ldrname)))
    ldrname)
    (command "dimstyle" "R" ldrname))))))
    ;;(princ "\n* Dimstyle RESET to previous Dimension Dimstyle *")
    (princ))
     
    Gary Fowler, Feb 3, 2005
    #19
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.