Cant stop a 'nil' value with lisp

Discussion in 'AutoCAD' started by devon, Jul 7, 2004.

  1. devon

    devon Guest

    Hi,

    I wrote this lisp which used dtext. I then tried to convert it to work with Mtext and am running into all sorts of problems...
    I get a "nil" return and this cancels the rest of the routine.

    Any help is much appreciated.

    This is my working DTEXT routine...
    (DEFUN C:3 ( / t_pt t_rot)
    (setq CL (getvar "clayer"))
    (checkst "S35" "iso3098b" 3)
    (checkla "t3" "4" "continuous")
    (setvar "textsize" (* 7 (checkva (checksp))))
    (setq t_pt (getpoint "\nStart point: "))
    (if (null t_pt)
    (command "dtext" "")
    (progn
    (setq t_rot (getangle t_pt "\nRotation Angle<0>: "))
    (if (null t_rot)(setq t_rot 0))
    (command "dtext" "j" "c" t_pt "" (rtd t_rot))
    (command "-layer" "s" CL "")
    )
    )
    (princ)
    )

    -------------------------------------
    If I change the Dtext to Mtext, i get an error in the middle of the routine...
    Start point: Rotation Angle<0>: Current text style: "S35" Text height: 4

    2D point or option keyword required.
    ; error: Function cancelled
    Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width]:
    --------------------------------------

    So I started playing , ended up with this 'nil' error even with the following string...
    (progn
    (command "mtext")
    )

    How do I get my origonal DTEXT lisp working as Mtext?
    I know I don't need all the point varibles. But even when I remove them I get an 'point' error when I goto pick the points for the Mtext dialogue box.
    You will notice this lisp goes back to a 'checking' lisp so ignore that side of it.


    Any thoughts?
     
    devon, Jul 7, 2004
    #1
  2. devon

    Joe Burke Guest

    Devon,

    Rough around the edges, but might get you pointed in the right direction. I think the
    texteval variable plays a role here.

    Regards
    Joe Burke

    (defun C:3 ( / t_pt t_rot CL )
    (setvar "texteval" 1)
    (setq CL (getvar "clayer"))
    (setq t_pt (getpoint "\nStart point: "))
    (if (null t_pt)
    (command "mtext" pause pause)
    (progn
    (setq t_rot (getangle t_pt "\nRotation Angle<0>: "))
    (if (null t_rot)(setq t_rot 0))
    (command "mtext" t_pt "r" (rtd t_rot) pause pause)
    (command "")
    (command "-layer" "s" CL "")
    )
    )
    (setvar "texteval" 0)
    (princ)
    )


    and am running into all sorts of problems...
    'point' error when I goto pick the points for the Mtext dialogue box.
     
    Joe Burke, Jul 7, 2004
    #2
  3. devon

    zeha Guest

    Something like i did


    (DEFUN C:3M ( / t_pt t_rot)
    (setq CL (getvar "clayer"))
    (checkst "S35" "iso3098b" 3)
    (checkla "t3" "4" "continuous")
    (setvar "textsize" (* 7 (checkva (checksp))))
    (setq t_pt (getpoint "\nStart point: "))
    (if (null t_pt)
    (command ".dtext" "")
    (progn
    (setq t_rot (getangle t_pt "\nRotation Angle<0>: "))
    (if (null t_rot)(setq t_rot 0))
    (initdia)
    (command ".MTEXT" "none" t_pt "j" "ML" "r" (rtd t_rot) "w" (* 20 (getvar "textsize")))
    ;;or
    ;;;(command ".MTEXT" "none" t_pt "j" "ML" "r" (rtd t_rot) "w" "0") with NoWrap
    (command "-layer" "s" CL "")
    )
    )
    (princ)
    )
     
    zeha, Jul 7, 2004
    #3
  4. devon

    Jürg Menzi Guest

    Hi Devon
    MTEXT requires 2 points or a width to specify the text window...
    See Harrie's sample
    'command' returns always 'nil'

    Cheers
     
    Jürg Menzi, Jul 7, 2004
    #4
  5. devon

    Don Butler Guest

    Which brings us to VL-CMDF:

    Command: (command "line")
    nil

    Command: (vl-cmdf "line")
    T

    Note the RETURN values of each method above...

    Don


    with Mtext and am running into all sorts of problems...
    get an 'point' error when I goto pick the points for the Mtext dialogue box.
     
    Don Butler, Jul 7, 2004
    #5
  6. devon

    Rudy Tovar Guest

    I tried it and get NULL function 'checkst'.

    with Mtext and am running into all sorts of problems...
    get an 'point' error when I goto pick the points for the Mtext dialogue box.
     
    Rudy Tovar, Jul 7, 2004
    #6
  7. devon

    devon Guest

    Thanks everyone for the great feedback!!

    Zeha, I used your example and have a question.

    On line 8 of your example, you have
    (command ".dtext" "")

    Why do you still need the dtext command in this routine?

    Thanks
    Devon
     
    devon, Jul 7, 2004
    #7
  8. devon

    CAB2k Guest

    Code:
    (defun c:3m (/ t_pt t_rot)
    (setq cl (getvar "clayer"))
    (checkst "S35" "iso3098b" 3)
    (checkla "t3" "4" "continuous")
    (setvar "textsize" (* 7 (checkva (checksp))))
    
    (if (setq t_pt (getpoint "\nStart point: "))
    (progn
    (setq t_rot (getangle t_pt "\nRotation Angle<0>: "))
    (if (null t_rot)
    (setq t_rot 0)
    (setq t_rot (rtd t_rot))
    )
    (initdia)
    (command "mtext" t_pt "j" "tc" "r" t_rot "w" 0 )
    (command "-layer" "s" cl "") ; reset the layer
    )
    )
    (princ)
    )
     
    CAB2k, Jul 8, 2004
    #8
  9. devon

    zeha Guest

    Devon,

    in your reply do yuo mean why .dtext in rather then dtext
    in that case it' for undefined Autocad commands that still be working.

    in other case i haven't change that part of your code.

    when you hit a return on the getpoint (thus not a point)
    it will go to the command dtext (like it was)

    Hope's this is the answer on your question

    Cheers
     
    zeha, Jul 8, 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.