Leader/Reactor woes

Discussion in 'AutoCAD' started by Josh, Apr 8, 2005.

  1. Josh

    Josh Guest

    I have a reactor designed to catch the leader command and, with viewtwist /= 0, make the leader text horizontal on the screen.

    My problem is that the tail of the leader won't show properly...sometimes it shows at the default non-viewtwisted angle or it doesn't show at all (see attached pic). I've tried redraw, entupd (which works occasionally) and vla-move to no avail...and, of course, I can't use (command "move" in a reactor. If I redraw or use another command after the leader command then the leader tail updates properly.

    Any ideas as to what I can do to "kick" the tail of the stupid leader?

    ;;;dim2hrz
    ;;;changes Leader text and dimension text to horizontal with respect to current viewtwist
    (defun dim2hrz (reactor data / mtext leader viewtwist dimension)
    ;;(princ "\nKickin' the reactor")
    (setq viewtwist (getvar "viewtwist"))
    (cond
    ((and (wcmatch (car data) "LEADER,QLEADER")
    (/= 0 viewtwist)
    (= "MTEXT" (dxf 0 (setq mtext (entget (entlast)))))
    )
    (progn
    (entmod (elist mtext 50 (- (* 2 pi) (getvar "viewtwist"))))
    ;;redraw (dxf -1 mtext) 1)
    (entupd (dxf -1 mtext))
    ;;(princ "\nKick the leader.")
    )
    )
    ((and (wcmatch (car data) "DIMLINEAR,DIMALIGNED")
    (/= 0 viewtwist)
    )
    (progn
    (setq dimension (entget (entlast)))
    (if (= (dxf 0 dimension) "DIMENSION")
    (entmod (elist dimension 51 viewtwist))
    )
    ;;(princ "\nKick the dimension.")
    )
    )
    )
    (PRINc)
    )

    (or rea:dim2hrz
    (progn
    (setq rea:dim2hrz
    (VLR-command-Reactor nil '(:)vlr-commandEnded . dim2hrz)))
    )
    (vlr-set-notification rea:dim2hrz 'active-document-only)
    )
    )

    (princ)

    ;;;change entity list contents if found otherwise add to list
    (defun elist (el grp new)
    (if (assoc grp el)
    (subst (cons grp new) (assoc grp el) el)
    (append el (list (cons grp new)))
    )
    )
    ;;;extract data from dotted pair
    (defun dxf (code elist) (cdr (assoc code elist)))
     
    Josh, Apr 8, 2005
    #1
  2. Josh

    Josh Guest

    Come on...does no one has any idea how to help me?
     
    Josh, Apr 8, 2005
    #2
  3. Josh

    Walt Engle Guest

    I don't use reactors and don't know that much about them. However, I can
    give you a lsp routine that will draw the leader you want:

    ; LDR.LSP
    (defun c:ldr ( / np g:ts ts n tdata p1 p2 p3 p4)
    (graphscr)
    (setvar "osmode" 0)
    (prompt "\nDraws leader with a standard arrowhead and text [NO
    OPTIONS]")
    (terpri)
    (setq g:ts (* 0.125 (getvar "dimscale")))
    (setq asz (getvar "dimasz"))
    (setq asz (* asz (getvar "dimscale")))
    (setq woah (/ asz 3.0))
    (setq ts g:ts)
    (setvar "textsize" ts)
    (setq n 0)
    (c:ldr1)
    (setq tdata nil)
    (while (/= "" (setq tl (getstring t "\nEnter text: ")))
    (setq tdata (cons tl tdata))
    )

    (setq htet (getdist (strcat "\n<Current text Height>/or Enter
    new text Height <"
    (rtos (/ (getvar "textsize")(getvar
    "dimscale"))) ">: ")))

    (if (null htet)(setq htet (/ (getvar "textsize")(getvar
    "dimscale"))))
    ;(setq ts (* htet (getvar "dimscale")))
    ;(if (<= htet 0.125)(command "-layer" "s" "0" ""))
    ;(if (> htet 0.125)
    ;(progn
    (if (> htet 0.375)(command "-layer" "s" "2" ""))
    ;)
    ;)

    (setq tdata (reverse tdata))
    (if (<= (car p1)(car p2))
    (progn
    (setq p3 (list (+ (car p2) g:ts)(cadr p2))
    p4 (list (+ (car p3) g:ts)(- (cadr p3)(* 0.5
    ts)))
    )
    (command "line" p2 p3 "")
    (repeat (length tdata)
    (command "text" p4 ts 0 (nth n tdata))
    (setq p4 (polar p4 (* 1.5 pi)(* 1.75 ts)))
    (setq n (1+ n))
    )
    )
    )
    (if (> (car p1)(car p2))
    (progn
    (setq p3 (list (- (car p2) g:ts)(cadr p2))
    p4 (list (- (car p3) g:ts)(- (cadr p2)(* 0.5
    ts)))
    )
    (command "line" p2 p3 "")
    (repeat (length tdata)
    (command "text" "r" p4 ts 0 (nth n tdata))
    (setq p4 (polar p4 (* 1.5 pi)(* 1.75 ts)))
    (setq n (1+ n))
    )
    )
    )
    (princ)
    (SETVAR "OSMODE" 32)
    )
    ;
    (defun c:ldr1 ()
    (initget 1)
    (setq p1 (getpoint "\nStart leader (Tip of arrowhead): "))
    (initget 1)
    (setq p2 (getpoint p1 "\nNext point on leader or end: "))
    (setq p3 (polar p1 (angle p1 p2) (* 1.5 g:ts)))
    (command "Pline" p1 "w" "0" (* 0.5 g:ts) p3 "w" "0" "" p2)
    (while
    (setq np (getpoint (getvar "lastpoint") "\nNext point on
    leader or <ENTER> to end: "))
    (if (/= np "")
    (progn
    (setq p1 (getvar "lastpoint"))
    (setq p2 np)
    (command p2)
    )
    )
    (if (= np "")
    (command "")
    )
    )
    )
     
    Walt Engle, Apr 9, 2005
    #3
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.