Lisp Won't Continue to Ne
I am just learning to write lisp and I wrote this basic function to erase any miscellaneous data that might be outside my drawing area, but it won't continue to the next command in the whole lisp routine.What am I missing to move to the next command in my lisp?(COMMAND "ZOOM" "E")(COMMAND "ZOOM" "SC" "0.75X")(COMMAND "ERASE" (SSGET"X") "R") I think I know this one.
Sorry if I am wrong this is my first attempt at answering a Lisp question
but you need a space follwing the command and option.
The space is interpreted as newline or pressing enter
"Zoom " Sorry Jeff, but that wasn't it.In the ERASE command, I have to make selection window(s) to remove the items that I don't want deleted.After I do this, the lisp stops and doesn't continue to the rest of commands within the lisp.Thanks for trying. First adjust your view in the acad dwg and try this .
(defun c:test (/ p1 p2 ss i sset s j e) (if (and (setq p1 (getvar 'vsmin)) (setq p2 (getvar 'vsmax)) ) (progn (setq ss (ssget "_w" p1 p2)) (repeat (setq i (sslength ss)) (setq sset (cons (ssname ss (setq i (1- i))) sset)) ) (setq s (ssget "_x")) (repeat (setq j (sslength s)) (if (not (member (setq e (ssname s (setq j (1- j)))) sset)) (entdel e) ) ) ) (princ) ) (princ))
Tharwat FYI future reference (COMMAND "ERASE" (SSGET"X") "R") this asking for 2 selection inputs the "X" is all then asking for a seperate remove they are independant of each other. You probably can not use the "R" to remove objects from the ssget
eg (command "erase" "wp" "CP" "W")is 3 seperate requests being added together.
Also not sure Z E, zooms total area and then going 75% would not necessarily get rid of junk. The view method above would be a better way. The zoom extents is so I can see everything in the drawing file.The zoom to 75% backs the view out just a little bit.That way when I make a selection window I can get objects on the edges without panning around or zooming out manually.
Tharwat - thank you, but that does not allow me to make a selection window of what I want to keep.In my very little experience with lisps, I am working on putting this functionality in what you have.Is there not a way to use what I have and make it work (which is obviously a lot easier for a simple minded person like me to understand)?
Hi ,
I think if you add only the zoom command to the routine it would work .
(COMMAND "ZOOM" "SC" "0.75X")
Or you can use the command zoom only and select two points and the routine would do the rest .
Good luck.
Tharwat Let me try to explain what I *believe* is happening....
Using this code as an example:
(COMMAND "ZOOM" "E")(COMMAND "ZOOM" "SC" "0.75X")(COMMAND "ERASE" (SSGET "X") "R")(command "._line") ;Animate), you will see that the code steps through this line BEFORE the Editor shows the selection set from which objects can be removed. The erase command is effective at allowing objects to be de-selected, however the code "doesn't continue" because it's already been passed over.</p>
Hope this helps! So you are saying lisps don't necessarily always read left to right, top to bottom? Give this a try:
(defun c:FOO(/ ss keep all) (vl-load-com) (if (setq ss (ssget "_:L")) (progn ((lambda (i / e) (while (setq e (ssname ss (setq i (1+ i)))) (setq keep (cons e keep)))) -1) (mapcar 'entdel (vl-remove-if '(lambda (e) (vl-position e keep)) ((lambda (i ss / e) (while (setq e (ssname ss (setq i (1+ i)))) (setq all (cons e all)))) -1 (setq ss (ssget "_x")))))) (prompt "\n** Nothing selected ** ")) (princ))
页:
[1]
2