+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Mar 2007
    Posts
    475

    Default Nothing changed, but now lisp gets error

    Registered forum members do not see this ad.

    when I created this, it worked fine. changed the command line color and had no errors. now its telling me
    Code:
    Program ERROR
    Resetting environment ; error: An error has occurred inside the *error* 
    functionbad argument type: consp nil
    Code:
    (defun c:PST (/ pickstyle)
    
    (if (= (getvar "pickstyle") 1) (setvar "pickstyle" 0) (setvar "pickstyle" 1))
    
    (if (= (getvar "pickstyle") 1) (CmdCol 255 0 0) (CmdCol 255 255 255))
      
    
    (defun CmdCol (r g b)
      (vl-load-com)
      (vla-put-TextWinBackgrndColor
        (vla-get-Display
          (vla-get-Preferences
            (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b))))
    
    (princ (getvar "pickstyle"))
    
    (princ)
    )
    OS: Windows 7 SP1
    Processor: Quad Core Xeon 2.27GHz
    Video Card: NVIDIA Quadro FX 1800 - 768MB
    Ram: 6GB
    Software: AutoCad 2009 32 bit - Microvellum V67

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Since your code does not define a local *error* function, it appears that you are running other LISP routines which are overriding the default *error* function and not resetting it (see here for more info).

    This won't solve your problems, but will give more information about the error; type at the command-line:

    Code:
    (setq *error* nil)
    Then re-run your above code.

    Move your IF statements below the CmdCol function definition, since otherwise the function is not defined when you call it.

    Lee
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Mar 2007
    Posts
    475

    Default

    thanks. it now says this
    Code:
    Command: pst ; error: no function definition: CMDCOL
    to I added "cmdcol" to the definitions
    but still get the same error

    Code:
    (defun c:PST (/ pickstyle CmdCol)
    
    (if (= (getvar "pickstyle") 1) (setvar "pickstyle" 0) (setvar "pickstyle" 1))
    
    (if (= (getvar "pickstyle") 1) (CmdCol 255 0 0) (CmdCol 255 255 255))
      
    
    (defun CmdCol (r g b CmdCol)
      (vl-load-com)
      (vla-put-TextWinBackgrndColor
        (vla-get-Display
          (vla-get-Preferences
            (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b))))
    
    (princ (getvar "pickstyle"))
    
    (princ)
    )
    OS: Windows 7 SP1
    Processor: Quad Core Xeon 2.27GHz
    Video Card: NVIDIA Quadro FX 1800 - 768MB
    Ram: 6GB
    Software: AutoCad 2009 32 bit - Microvellum V67

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,616

    Default

    Remove the variable CmdCol from the sub-function and try again
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Quote Originally Posted by Lee Mac View Post
    Move your IF statements below the CmdCol function definition, since otherwise the function is not defined when you call it.
    ^^ Re-read.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Mar 2007
    Posts
    475

    Default

    ok this one works now

    Code:
    (defun c:PST (/ pickstyle CmdCol)
    
    (defun CmdCol (r g b )
      (vl-load-com)
      (vla-put-TextWinBackgrndColor
        (vla-get-Display
          (vla-get-Preferences
            (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b))))
    
    
    (if (= (getvar "pickstyle") 1) (setvar "pickstyle" 0) (setvar "pickstyle" 1))
    
    (if (= (getvar "pickstyle") 1) (CmdCol 255 0 0) (CmdCol 255 255 255))
    
    
    (princ (getvar "pickstyle"))
    
    (princ)
    )
    OS: Windows 7 SP1
    Processor: Quad Core Xeon 2.27GHz
    Video Card: NVIDIA Quadro FX 1800 - 768MB
    Ram: 6GB
    Software: AutoCad 2009 32 bit - Microvellum V67

  7. #7
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Mar 2007
    Posts
    475

    Default

    Quote Originally Posted by Lee Mac View Post
    ^^ Re-read.
    missed that the first time. did that and removed the subfunction def.
    now works
    thanks
    OS: Windows 7 SP1
    Processor: Quad Core Xeon 2.27GHz
    Video Card: NVIDIA Quadro FX 1800 - 768MB
    Ram: 6GB
    Software: AutoCad 2009 32 bit - Microvellum V67

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Quote Originally Posted by MikeP View Post
    missed that the first time. did that and removed the subfunction def.
    now works
    thanks
    Good stuff.

    But you might want to still investigate the issue with the *error* function not being reset in another LISP program you are running.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #9
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Mar 2007
    Posts
    475

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Lee Mac View Post
    Good stuff.

    But you might want to still investigate the issue with the *error* function not being reset in another LISP program you are running.
    i read through that link you send. Im still not sure to find a error in another program. I understand it might not be resetting be cause i may have hit esc while a command was half completed. but im not sure how to track it down
    OS: Windows 7 SP1
    Processor: Quad Core Xeon 2.27GHz
    Video Card: NVIDIA Quadro FX 1800 - 768MB
    Ram: 6GB
    Software: AutoCad 2009 32 bit - Microvellum V67

Similar Threads

  1. Error lisp
    By vnanhvu in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 10th Jun 2011, 08:20 am
  2. Changed from Autocad std to Autocad LT and wondered where the lisp went
    By jaccna in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 5
    Last Post: 1st Apr 2011, 04:15 pm
  3. error on lisp
    By sachindkini in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 31st Mar 2010, 12:39 pm
  4. LISP Error
    By bradb in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 14th Jul 2009, 01:49 pm
  5. Lisp error
    By yawdapaah in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 26th Mar 2009, 03:21 pm

Bookmarks

Posting Permissions

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