Code:(command "_.ucs" "_P")
Registered forum members do not see this ad.
Dear masters.
After setting the UCS "OB" as continue the execution of the routine?
Once completed the cycle, how to reset the previous UCS?
Code:;;teknomatika (defun c:asna (/ hdist vdist divn distseg pti1 pts1 pti2) (command "ucs" "OB" "pause" "");;The execution is stopping here. (setq hdist (getdist "\nHorizontal Distance: ")) (setq vdist(getdist "\nVertical Distance ")) (setq divn (getint "\nDivisons Number: ")) (setq distseg (/ hdist divn)) (setq pti1 (getpoint "\nStart Point: ")) (setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1))) (setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1))) (repeat divn (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""") (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1))) (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1))) (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1))) (princ) );repeat ) (prompt "\nTo invoque command type ASNA ")
Code:(command "_.ucs" "_P")
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
You need to write it like:
Code:(command "_UCS" "_OB" pause)
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Tanks.
Ok Works. But it ends with a weird "Command: nil"
Is it so?
Code:;;teknomatika (defun c:asna (/ oldclay hdist vdist divn distseg pti1 pts1 pti2) (setq oldclay (getvar "clayer")) (command "layer" "new" "asnas" "color" "8" "asnas" "") (command "layer" "set" "asnas" "") ;;(command "_.ucs" "_P");; Not work (command "_UCS" "_OB" pause) (setq hdist (getdist "\nHorizontal Distance: ")) (setq vdist(getdist "\nVertical Distance ")) (setq divn (getint "\nDivisons Number: ")) (setq distseg (/ hdist divn)) (setq pti1 (getpoint "\nStart Point: ")) (setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1))) (setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1))) (repeat divn (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""") (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1))) (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1))) (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1))) (princ) );repeat (setvar "clayer" oldclay) (command "_.ucs" "_P") ) (prompt "\nTo invoque command type ASNA ")
I did some corrections to your code:
- there is no need to disable AutoOsnap when end the command call,
- the repeat of that PRINC call is useless
- in order to allow the routine to exit quietly you need to add a PRINC call as last statement; this will get rid of that final nil.
Code:... (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2"_non""") (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1))) (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1))) (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))(princ));repeat (setvar "clayer" oldclay) (command "_.ucs" "_P") (princ) )
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
teknomatika,
Aside: do you understand why the 'nil' was returned to the command-line in your original code?
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Registered forum members do not see this ad.
To clarify for you: In your original code, nil is returned to the command-line because the last evaluated expression enclosed by your defun expression is the command expression, and the command function always returns nil (as stated in the documentation).
Note this behaviour from the Visual LISP IDE Help Documentation on the defun function:
This inherent behaviour is intuitive when definining 'subfunctions', for example:Originally Posted by VLIDE Help
When called with a numerical argument, the above function will return the result of the last expression evaluated inside the function definition (defun), that is, the call to the + function, returning the supplied argument plus 2:Code:(defun add2 ( x ) (+ x 2))
Note that this is a property of the defun function and hence applies to all functions defined in such a way. Those functions whose symbol name is prefixed with c: are treated in exactly the same way - the c: prefix simply allows the function to be called as a command directly from the command-line.Code:_$ (add2 5) 7
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Bookmarks