Lisp leader routine - works in ACAD 2002 but not in BCAD V.11

Here is a lisp rouine (sort of hacked together) that I use in AutoCAD and that I am trying to use in Bricscad V11.  It allows you to indicate a leader start point, and then indicate if the leader goes off to the right (with left-justified MTEXT) or to the left (with right-justified MTEXT).  

After loading the .lsp file, you type  DR  to get the routine started.

When the leader goes to the right side (with left-justified MTEXT) it works ok.  But when it goes to the left, the text is justified correctly but placed in the wrong location.  This works correctly in AutoCAD 2002, though.

Is this a problem with my routine, or is it something that I should submit a support request for?

Thanks.

 

; Leader routine -- simplifies drawing angled leaders and using MTEXT notes.(setq note_width nil) ; initialize this when loaded.(defun dtr (a) (* pi (/ a 180.0)))               ;degrees to radians(defun rtd (r) (* 180.0 (/ r pi)))               ;radians to degrees(defun options (/     first_point     last_point) (setq first_point (getpoint "\nPick first point to define width: "))    (setq last_point (getpoint first_point "\nPick second point to define width: "))    (setq note_width (distance first_point last_point)) (prompt "\n ")                                  ;blank line)                                                                                  (defun c:drr (/ os or txtsz pt1 pt2 pt3 pt4 just sid) (setvar "cmdecho" 0)                            ;turn command echo off        (setvar "cmddia" 1)                             ;to enable MTEXT dialog box with qleader  (setq or (getvar "orthomode"))                  ;get current ortho mode        (setq os (getvar "osmode"))                     ;get current object snaps        (setvar "osmode" 0)                             ;turn off all object snaps for now  (setq txtsz (getvar "textsize"))                ;get current text size  (setq note_width (* txtsz 20.)) (setvar "orthomode" 0)                          ;turn ortho mode off    (graphscr)                                      ;turn to graphics screen    (prompt "\n ")                                  ;blankline  (setq pt1 nil)  (while (= pt1 nil)      (progn          (setq pt1 (getpoint "\nPick 1st point or Return for <Options>..."));pick point 1 or return for help           (if (= pt1 nil) (options))                ;options if return was selected       ) ;progn    ) ; while   (setvar "orthomode" 0)                          ;turn ortho off (prompt "\n ")                                  ;blank line (setq pt2 (getpoint pt1 "\n Pick 2nd point.. "));pick point 2        (setvar "orthomode" 1) (prompt "\n ")      (setq sid (getorient pt2 "\nSelect Left side or Right. "));pick left or right justified side      (if (= sid (dtr 180.0))                         ;if 180 degrees          (setq pt3 (polar pt2 (dtr 180.0) txtsz))    ;calculate point 4 if 180 degrees          (setq pt3 (polar pt2 0 txtsz))              ;calculate point 3 if 0 degrees      )                                               ;end if      (command "LEADER" pt1 pt2 pt3 "" "" "n")      (if (= sid (dtr 180.0))                         ;if 180 degrees          (setq pt4 (polar pt3 (dtr 180.0) (/ txtsz 1.5)))              (setq pt4 (polar pt3 0 (/ txtsz 1.5)))                   )       (setq pt4 (polar pt4 90 (/ txtsz 2.0)))        ;make top of mtext box a bit higher                                           (if (= sid (dtr 180.0))          (setq just "TR")                            ;top right justification          (setq just "TL")                ;top left justification      )      (setvar "orthomode" or)                         ;restore original value      (setvar "osmode" os)                            ;restore object snaps      (setvar "cmdecho" 1)      (command "MTEXT" pt4 "j" just "s" "STANDARD" "w" note_width)(princ)) ; end of leader routine

 

 

Comments

  • Yep, file a support request.  I get two different results when I do it manually or using your code.

  • There is a minor difference with LEADER command, compared to Acad.
    Please try -LEADER in your code, will probabl help.

  • Changing to -LEADER did not work.  Actually I think the problem is with the implementation of MTEXT in the lisp code vs. the command line.  I have submitted a support request.

  • @ John: Try this:

    ; Leader routine -- simplifies drawing angled leaders and using MTEXT notes.

    (setq *note_width* nil) ; initialize this when (re)loaded.

    (defun c:drr (/ just orth os pt1 pt2 pt3 pt4 pt5 sid txtsz)
    (graphscr) ;turn to graphics screen
    (setq orth (getvar "orthomode")) ;get current ortho mode (let's not use OR here)
    (setq os (getvar "osmode")) ;get current object snaps
    (setvar "orthomode" 0) ;turn ortho mode off
    (setvar "osmode" 0) ;turn off all object snaps for now
    (setq txtsz (getvar "textsize")) ;get current text size
    (if (not *note_width*)
    (setq *note_width* (* txtsz 20))
    )
    (while (not pt1)
    (setq pt1 (getpoint (strcat "\nCurrent note width is " (rtos *note_width*) "; pick 1st point or Return to change note width...")))
    (if (not pt1)
    (setq *note_width* (getdist "\nNew note width: "))
    )
    )
    (setq pt2 (getpoint pt1 "\nPick 2nd point.. "))
    (setvar "orthomode" 1)
    (setq sid (getorient pt2 "\nSelect Left side or Right. "))
    (if (equal sid pi 1e-9) ;if 180 degrees
    (setq
    just "TR" ;top right justification
    pt3 (polar pt2 pi txtsz)
    pt4 (polar pt3 pi (/ txtsz 1.5))
    pt4 (polar pt4 (/ pi 2) (/ txtsz 2.0)) ;make top of mtext box a bit higher
    pt5 (polar pt4 pi *note_width*)
    )
    (setq
    just "TL" ;top left justification
    pt3 (polar pt2 0 txtsz)
    pt4 (polar pt3 0 (/ txtsz 1.5))
    pt4 (polar pt4 (/ pi 2) (/ txtsz 2.0)) ;make top of mtext box a bit higher
    pt5 (polar pt4 0 *note_width*)
    )
    )
    (command "LEADER" pt1 pt2 pt3 "" "" "n")
    (setvar "cmdecho" 1)
    (command "MTEXT" pt4 "j" just "s" "STANDARD" "h" txtsz pt5)
    (while (/= (getvar "cmdactive") 0)
    (command pause)
    )
    (setvar "orthomode" orth) ;restore original value
    (setvar "osmode" os) ;restore object snaps
    (princ)
    )
  • That fixed it!  Thanks for your help -- this is much appreciated!

This discussion has been closed.