Author Topic: error in a lisp routine  (Read 1635 times)

0 Members and 1 Guest are viewing this topic.

squareknees

  • Guest
error in a lisp routine
« on: July 10, 2015, 08:27:48 AM »
I am new to this site but have been working in AutoCAD for 15 years. Never got the hang of creating a lisp routine. So I find good lisp routines online and use them.
I found one that is great but I have an issue when I auto load into the program. I get a weird start up error.
I have found which lisp routine it is that does it but I would like to have it accessible all time.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ist ( / e i j k)
  2.   ;(setq i (/ pi 6.) j -1.)
  3.   (setq i 0 k (/ pi 6.) j -1.)
  4.   ;; © Lee Mac 2011
  5.   (if
  6.     (and
  7.       (setq e (car (entsel "\nSelect Text: ")))
  8.       (eq (vla-get-Objectname (setq e (vlax-ename->vla-object e))) "AcDbText")
  9.       (princ "\nPress [Tab] to Change Projection ")
  10.       )
  11.     (while (= 9 (cadr (grread nil 14 0)))
  12.            ;(vla-put-rotation e i)
  13.            (vla-put-rotation e (* k (1- (* 2 (setq i (rem (+ i (max 0 (setq j (- j)))) 3))))))
  14.            ;(vla-put-obliqueangle e (setq i (* i (setq j (- j)))))
  15.            (vla-put-obliqueangle e (* j k))
  16.            )
  17.     )
  18.   (princ)
  19.   )
  20. (c:ist)

when I start AutoCAD with this auto loaded into the drawing it  has a startup error.

s::startup-load

I have to escape a few times to get going in the drawing

Thanks for any help


Edit: I added code tags to the code in this post to make it more readable.
REF: https://www.theswamp.org/index.php?topic=48309.0
« Last Edit: July 10, 2015, 09:21:47 AM by John Kaul (Se7en) »

ChrisCarlson

  • Guest
Re: error in a lisp routine
« Reply #1 on: July 10, 2015, 09:06:23 AM »
I loaded it up fine and it works? I'd just remove that bottom (c:ist), it's annoying when a routine attempts to start automatically.

ChrisCarlson

  • Guest
Re: error in a lisp routine
« Reply #2 on: July 10, 2015, 09:07:56 AM »
Lee did revise that code to error when mtext is selected, I'm sure the routine could be modified to include mtext as well.

http://www.theswamp.org/index.php?topic=37429.0

hmspe

  • Bull Frog
  • Posts: 362
Re: error in a lisp routine
« Reply #3 on: July 10, 2015, 09:18:17 AM »
The original thread is here: http://www.theswamp.org/index.php?topic=37429.0

I suspect that all that is needed is to remove the    (c:ist)    at the end of the routine.  That line runs the function automatically when the routine is loaded.  If you are loading a function when needed that makes some sense, but if you area loading a function when you start your CAD program a function like this generally should not automatically run.

You might find it easier to use the formatting that Stefan used in the last post of page 1 of http://www.theswamp.org/index.php?topic=37429.0 instead of the formatting at https://lispbox.wordpress.com/2015/02/17/creates-isometric-text/.  I find indenting makes it much easier to follow the code.  Stefan's code is also a modification of Lee's code, so Stefan commented out several lines and inserted modified lines just below the lines he commented out.  I would delete the three lines starting with   ;(   .  I would also change the copyright to:   
;; original © Lee Mac 2011, from http://www.theswamp.org/index.php?topic=37429.0
"Science is the belief in the ignorance of experts." - Richard Feynman