Results 1 to 8 of 8

Thread: "No function definition" After COMMAND Call

  1. #1
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Question "No function definition" After COMMAND Call

    Hey All,

    Simple little problem, lisp works fine, but I get an annoying "error: no function definition: nil".

    I know this line of code returns nil, but I don't know how to stop the error... Any ideas?
    Code:
    (command "_.shademode" "G")
    Full lisp (to toggle wireframe/shaded modes):

    Code:
    (defun c:togglevs (/ cvs)       (setq cvs
    	      (assoc 281 (entget (tblobjname "VPORT" "*ACTIVE")))
    	     )
      (setq cvs (cdr cvs))
      
      (cond
        (
         (OR
         (= cvs 0)
         (= cvs 1)
         (= cvs 2)
         )
         (
          (command "_.shademode" "G")
          (prompt "Toggling to Shaded mode")
          )
         )
        (
         (OR
         (= cvs 4)
         (= cvs 6)
         )
         (
          (command "_.shademode" "3D")
          (prompt "Toggling to Wireframe mode")
          )
         )
        )
      (princ)
      )

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    I guess you have an extra parenthesis before that command call which is no needed.

  3. #3
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Quote Originally Posted by Tharwat View Post
    I guess you have an extra parenthesis before that command call which is no needed.
    That parentheses wraps the "command" and "prompt" statements together as the "then" part of the COND statement.

    Code:
    (
       (command "_.shademode" "G")
       (prompt "Toggling to Shaded mode")
    )

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Quote Originally Posted by stusic View Post
    That parentheses wraps the "command" and "prompt" statements together as the "then" part of the COND statement.

    Code:
    (
       (command "_.shademode" "G")
       (prompt "Toggling to Shaded mode")
    )
    That is not needed with cond function nor even the progrn function

  5. #5
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Quote Originally Posted by Tharwat View Post
    That is not needed with cond function nor even the progrn function
    How would I separate the "ifs" from the "thens"?

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Try this UNTESTED :

    Code:
    (defun c:togglevs (/ cvs)
      (if (setq csv (tblobjname "VPORT" "*ACTIVE"))
        (setq cvs (cdr (assoc 281 (entget csv))))
      )
      (cond
        ((<= 0 cvs 2)
         (command "_.shademode" "G")
         (prompt "Toggling to Shaded mode")
        )
        (
         (OR
           (= cvs 4)
           (= cvs 6)
         )
         (command "_.shademode" "3D")
         (prompt "Toggling to Wireframe mode")
        )
      )
      (princ)
    )

  7. #7
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Interesting.

    I tried your code: works.
    I tried my code, but removed the parentheses as you suggested: works.

    Note: I see now how the COND statement still works without the parentheses. Thanks

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: "No function definition" After COMMAND Call

    Quote Originally Posted by stusic View Post
    Interesting.

    I tried your code: works.
    I tried my code, but removed the parentheses as you suggested: works.

    Note: I see now how the COND statement still works without the parentheses. Thanks
    Excellent. You're welcome.

Similar Threads

  1. Replies: 9
    Last Post: 2014-06-23, 05:16 PM
  2. S::Startup ignores lisp "command" function
    By sshively.230498 in forum CAD Management - General
    Replies: 2
    Last Post: 2010-04-20, 12:09 PM
  3. Command: "" Function confusion
    By johannvonspiralspine in forum AutoLISP
    Replies: 3
    Last Post: 2008-04-30, 02:20 PM
  4. Replies: 41
    Last Post: 2007-11-20, 12:32 AM
  5. Replies: 39
    Last Post: 2005-11-04, 08:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •