• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

non-functional lisp routine

  • Thread starter Thread starter Angelo2449
  • Start date Start date

Angelo2449

Guest
Hello everyone,
I'm going crazy about this little routine that doesn't work.
Code:
 (defun c:prova (/ cx cy cx cyx cyyy xyz)

(setq spotted (getpoint "\nclick point"))
(command "_circle" point 0.15)

(setq cx (car point))
(setq cy)

(setq cxx (+ cx 0.20))
(setq cyyy (+ cy 0.25))

(setq xyz (list cxx cyyy 0.00)

(command "_circle" xyz 0.40)
(command "_change" "_last" "_p" "_c" "_red"")

)
Thank you.
 
to me line by line works.
try to remove local variables
(defunc c: test (/ cx cy cx cyx cyy xyz) -> (defunc c: test ()
 
Code:
(defun c:prova (/ cx cy cx cyx cyyy xyz)

(setq spotted (getpoint "\nclick point"))

(setosnaponoff "off")

(command "_circle" point 0.15)

(setq cx (car point))
(setq cy)

(setq cxx (+ cx 0.20))
(setq cyyy (+ cy 0.25))

(setq xyz (list cxx cyyy 0.00)

(command "_circle" xyz 0.40)

(command "_change" "_last" "_p" "_c" "_red"")

(setosnaponoff "on")

)

; turn on or off osnap, equivalent to f3 key
(defun setosnaponoff(mode/osmode)
(setq osmode (getvar "osmode")
(if)
(if) osmode 16384)
(Setvar "osmode" (- osmode 16384))
)
(if) osmode 16384)
(setvar "osmode" (+ osmode 16384))
)
)
)
You have to pay attention to the osnap, if you don't care.
 
I had not thought of the osnap because usually before each procedure I enter
(setq oldosmode (getvar "osmode")
(Setvar "osmode" 0)

and at the end
(setvar "osmode" oldosmode)

so that the procedure is absolutely transparent to the operator and not influenced by the osnap.
 
by making changes to system variables it would be good to predispose a fault management for restoration in case of forced output.
to avoid... there is always the good "_non"
(command "_circle") "_non" xyz 0.40
 
sometimes the lisp lets me be disconcerted, a routine works, another similar does not work!
i'm sure i'm wrong, but the syntheticity of language, leads to frequent errors but, which are not so detectable in programming.
i have to get used to it.
by the way, the routine works well, suddenly, without changing code, it works!
 
Let's see if I understand:
- Define a *error* function
- before the list, select the value of osmode
- in case of routine error, the lisp intercepts the error (as?), the *error* function that restores the osmode and visifies the error message.

what I do not understand is how the lisp intercepts the error, then launching the *error* routine automatically.
 
a routine has a start and an end, when this stops autolisp always evaluates if there is a function *error*
 
Last edited:

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top