woodman78 Posted January 21, 2013 Posted January 21, 2013 I have this lisp to select an entity by a crossing window but I am getting an error. Can anyone help? (defun c:OSi ( /p1 p2 sel1) (setq p1 476.702,-48.6347) (setq p2 472.854,-44.789) (setq sel1 (ssget "w" p1 p2)) (command "erase" sel1 "" ) (princ) ) Thanks. Quote
Tharwat Posted January 21, 2013 Posted January 21, 2013 (defun c:OSi (/ p1 p2 sel1) (setq p1 (list 476.702 -48.6347)) (setq p2 (list 472.854 -44.789)) (if (and (listp p1) (listp p2) (setq sel1 (ssget "w" p1 p2))) (command "_.erase" sel1 "") ) (princ) ) Quote
Lee Mac Posted January 21, 2013 Posted January 21, 2013 Your points must be lists, i.e. (setq p1 '(476.702 -48.6347)) In AutoLISP 476.702,-48.6347 is just a symbol - it not a string or a list and has no numerical value (it holds no value whatsoever unless defined using a set[q] expression) Quote
woodman78 Posted January 21, 2013 Author Posted January 21, 2013 Thanks for the help Tharwat and LeeMac. Quote
Tharwat Posted January 21, 2013 Posted January 21, 2013 Thanks for the help Tharwat . Not a problem . Quote
bababarghi Posted March 15, 2017 Posted March 15, 2017 (defun c:OSi (/ p1 p2 sel1) (setq p1 (list 476.702 -48.6347)) (setq p2 (list 472.854 -44.789)) (if (and (listp p1) (listp p2) (setq sel1 (ssget "w" p1 p2))) (command "_.erase" sel1 "") ) (princ) ) Is there any reason why following variation is not working? (i.e. not erasing): (defun foo (p1 p2 / sel1) (if (= (getvar "TILEMODE") 1) (setvar 'TILEMODE 0) ) (if (and (listp p1) (listp p2) (setq sel1 (ssget "w" p1 p2))) (command "_.Erase" sel1 "") ) (princ) ) (foo '(115 15) '(131 21)) The problem seems to be switching to Paper space. If I drag the lisp onto drawing while paper space is active, it works fine. However, being in Model Space, the code just activates the Paper space and that's about it. Quote
Tharwat Posted March 15, 2017 Posted March 15, 2017 The problem seems to be switching to Paper space. If I drag the lisp onto drawing while paper space is active, it works fine. However, being in Model Space, the code just activates the Paper space and that's about it. Hi, Try to add the following codes with AND function: (setvar 'CTAB (getvar 'CTAB)) Quote
Lee Mac Posted March 15, 2017 Posted March 15, 2017 Try to add the following codes with AND function: (setvar 'CTAB (getvar 'CTAB)) This will have no effect - you are setting CTAB to its existing value. I would suggest removing the lines: (if (= (getvar "TILEMODE") 1) (setvar 'TILEMODE 0) ) Quote
Tharwat Posted March 15, 2017 Posted March 15, 2017 This will have no effect - you are setting CTAB to its existing value. I am setting the CTAB after moving to last visited paper space to allow the ssget to work in that space but it seems that it is working without it after testing it a few seconds ago. I would suggest removing the lines: (if (= (getvar "TILEMODE") 1) (setvar 'TILEMODE 0) ) The guy who asked for the an answer, needs to run the codes in paper space and that's why they included that fore-said codes at the beginning. Quote
bababarghi Posted March 15, 2017 Posted March 15, 2017 Hi,Try to add the following codes with AND function: (setvar 'CTAB (getvar 'CTAB)) No change. I tried like so: (defun foo (p1 p2 / sel1) (if (= (getvar "TILEMODE") 1) (setvar 'TILEMODE 0) ) (if (and (setvar 'CTAB (getvar 'CTAB)) (listp p1) (listp p2) (setq sel1 (ssget "w" p1 p2))) (command "_.Erase" sel1 "") ) (princ) ) (foo '(115 15) '(131 21)) This will have no effect - you are setting CTAB to its existing value. I would suggest removing the lines: (if (= (getvar "TILEMODE") 1) (setvar 'TILEMODE 0) ) The texts that I want to delete are in paper space. Most of drawings have been last saved&closed in Model space. I need this bit of code to switch over. Quote
Lee Mac Posted March 15, 2017 Posted March 15, 2017 I am setting the CTAB after moving to last visited paper space to allow the ssget to work in that space but it seems that it is working without it after testing it a few seconds ago. Consider that: (setvar 'ctab (getvar 'ctab)) Is no different to doing: (setq a a) You are setting a system variable to the value it already holds. Quote
Tharwat Posted March 16, 2017 Posted March 16, 2017 The texts that I want to delete are in paper space. Most of drawings have been last saved&closed in Model space. I need this bit of code to switch over. It did work for me. Consider that:(setvar 'ctab (getvar 'ctab)) Is no different to doing: (setq a a) You are setting a system variable to the value it already holds. Lee I am not a new to AutoLISP to say that and I am not giving replies by guessing. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.