LISP routine stopped working

LISP routine stopped working

alaneZ8RDC
Participant Participant
641 Views
9 Replies
Message 1 of 10

LISP routine stopped working

alaneZ8RDC
Participant
Participant

I am running CAD 2025, but the lisps I have were from 2026. There were a few minor changes I needed to make but overall everything was working fine.

All of a sudden, my master lisp file isn't working. For example, I have two lisps - TQP and TQP24. Only the first one will run.

Some lisp routines are singular (such as TWIST). However, it doesn't work if the lisp is in the master lsp file. If I copy and paste into its own .lsp and appload it will work. It's driving me nuts, I use this all the time.

See below - the end of one lisp to the beginning of the next one.

 

 

 

princ)
)
 
 
;****************************************************************************
; -----TW----- DVIEW TWIST 
;****************************************************************************
 
;;;  LISP  uses two points or an input angle to
;;;    twist the current view using the the dview command.
;;;    the snapangle variable is reset to make the cursor
;;;    appear horizontal.
 
;;;;The dtr funtion converts degrees to radians
;;;;The rtd funtion converts radians to degrees
 
(defun RTD (/ANG) (/ (* ANG 180.0) pi))
 
(defun DTR (/ANG) (* pi (/ ANG 180.0)))
 
(defun C:TW (/ P1 P2 ANG)
;;;  store the cmdecho, osnapcoord, osmode and orhtomode system varibles
  (setq CE-SAV (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq OSCOORD-SAV (getvar "osnapcoord"))
  (setvar "osnapcoord" 1)
  (setq ORTHOMODE-SAV (getvar "orthomode"))
  (setvar "orthomode" 0)
  (princ
    "\nTwist view and cursor angle by picking two point or entering an angle
"
  ) ; _ end ofPRINC
  (if (setq P2 (getpoint
"\nFirst point(left) <Press Enter to input an angle>: "
       ) ; _ end of GETPOINT
      ) ;_ end of SETQ
    (progn (initget 1)
   (setq P1  (getpoint "\nSecond point(right): " P2)
ANG (angle P2 P1)
   ) ;_ end of SETQ
   (command "DVIEW" "L" "" "TW" (- 360 (RTD ANG)) "")
   (setvar "SNAPANG" ANG)
    ) ;_  end of PROGN
    (progn (setq ANG (getangle "\nAngle: "))
   (command "DVIEW" "L" "" "TW" (- 360 (RTD ANG)) "")
   (setvar "SNAPANG" ANG)
    ) ;_ end of PROGN
  ) ;_  end of IF
  (setvar "cmdecho" CE-SAV)
  (setvar "osnapcoord" OSCOORD-SAV)
  (setvar "orthomode" ORTHOMODE-SAV)
;;; print the rotation angle to the screen:  converts string to local units
  and
  precision
  (princ
    (strcat "\nTwist angle: "
    (angtos ANG (getvar "aunits") (getvar "auprec"))
    ) ;_ end of strcat
  ) ;_ end of princ
  (princ)
) ;_  end of DEFUN
 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DRAWING OPENING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
;;;THE FOLLOWING IS FOR TOPEN

 

0 Likes
Accepted solutions (1)
642 Views
9 Replies
Replies (9)
Message 2 of 10

paullimapa
Mentor
Mentor

Like you said Twist works fine when loaded separately from the master lisp file.

Perhaps there's something in the master lisp file that fails preventing the defun c:TW from ever loading?

Could you attach the entire master lisp function here for examination?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 10

Sea-Haven
Mentor
Mentor

Do a (princ 1) ie (princ X) put it as 1st line in each C: defun that way you will see say 123456 and so on, can then see if a number is missing. Or (princ "\ndefuname") its an old fashioned way of finding where it gets to.

Message 4 of 10

DGCSCAD
Advisor
Advisor

I use this method as well. 🙂

 

Examples:

(defun c:myfunction ()

(princ "\nTesting myfunction")

... the rest of the code

 

(defun c:myotherfunction ()

(princ "\nTesting myotherfunction")

... the rest of the code

 

This way, when something errors out I know where to look, which would be the last function name sent to the command line.

 

When debugging/developing I'll leave it uncommented, but when all is finished and running as designed, a simple find and replace "all" comments them all out:

 

Find:

(princ "\nTesting

Replace:

;(princ "\nTesting

AutoCad 2018 (full)
Win 11 Pro
Message 5 of 10

alaneZ8RDC
Participant
Participant

Thank you for the replies! I am going to try the numbering system and see if I can sus out the problem, but here is the master file in the meantime.

0 Likes
Message 6 of 10

paullimapa
Mentor
Mentor
Accepted solution

Attempting to load this lisp right away returns the following error:

paullimapa_0-1767892309858.png

In the lisp file you have a number of problems including:

1) princ functions missing open parenthesis

2) if function missing closing parenthesis

3) defun function missing closing parenthesis

Whoever worked on this should not be allowed to do so again until they're using a lisp editor like Visual Studio Code which Autodesk recommends which provides a feature to check for matching parenthesis.

I cannot guarantee after all my adjustments made in the lisp will function but at least it now loads without error and TW does work

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 10

alaneZ8RDC
Participant
Participant

Thank you for your help. I will look into the Visual Studio Code program.

0 Likes
Message 8 of 10

paullimapa
Mentor
Mentor

you're welcome.... cheers!!!

PS: here's a post from Autodesk on VS Code:

https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-B1612444-8F27-44BF-8339-A556351C8842


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 10

Sea-Haven
Mentor
Mentor

Just another suggestion a lot of us use NOTEPAD++ its free and has a lot of good functions, when you save as a lsp file it will show your brackets and you can track down via color missing brackets, if you use ACAD you can download an extra add on "ActiveX Plugin" and run your code from Notepad++ a great feature. In image I have clicked on third line, the white brackets show a matched pair of brackets. you can say click on the very 1st line at the defun and scroll down looking for say missing close bracket in the master defun.

SeaHaven_0-1767915271706.png

PS can have different color schemes.

 

Message 10 of 10

alaneZ8RDC
Participant
Participant

Thank you!  I'll look into that too.

0 Likes