Wipeout routine

Wipeout routine

C.Utzinger
Collaborator Collaborator
1,096 Views
2 Replies
Message 1 of 3

Wipeout routine

C.Utzinger
Collaborator
Collaborator

Hi

 

I have a Little Problem with the following code:

 

(defun c:<WipeoutNeu (/ *error* lay cmd ent)

	(defun *error* (errmsg)
    	(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      	   (princ (strcat "\nError: " errmsg)))
    	(setvar 'CLAYER lay)
	(setvar 'CMDECHO cmd)
	(command-s "_.undo" "_end")
        (command-s "_.u")
	(princ "\nAlles rückgängig gemacht! ")
    	(princ))

	(command "_.undo" "_begin")
	(setq lay (getvar 'CLAYER)
              cmd (getvar 'CMDECHO))
	(setvar 'CMDECHO 0)
  	(command "_.-LAYER" "_m" "-I-Wipeout" "_co" "255" "-I-Wipeout" "")
	
	(if (setq ent (car (entsel "\nGeschlossene Polylinie wählen oder <Neue zeichnen>: ")))
	    (progn
		(command "_.wipeout" "_p" ent "_y")
		(princ "\nWipeout erstellt! "))
	    (progn
		(command "_pline" (while (> (getvar "cmdactive") 0) (command pause)))
		(command "_.wipeout" "_p" "_last" "_y")
		(princ "\nWipeout erstellt! ")))

	(command "_.undo" "_end")
	(setvar 'CLAYER lay)
	(setvar 'CMDECHO cmd)
	(prin1) 
) ; end of defun

 

If you select a unclosed polyline (I know you should select a closed one 😉 ), then the Routine Ends normally with the princ "Wipeout erstellt!".

 

How can i fix this?

 

Regards

0 Likes
Accepted solutions (2)
1,097 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Perhaps like this?

 

  (if (setq ent (car (entsel "\nGeschlossene Polylinie wählen oder <Neue zeichnen>: ")))
    (if (and (= "LWPOLYLINE" (cdr (assoc 0 (entget ent)))) ; selected ent is lwpolyline
             (= 1 (logand 1 (cdr (assoc 70 (entget ent))))) ; it's closed
             )
      (progn
        (command "_.wipeout" "_p" ent "_y")
        (princ "\nWipeout erstellt! "))
      (princ "\nError: Required closed polyline!"))
    (progn
      (command "_pline" (while (> (getvar "cmdactive") 0) (command pause)))
      (command "_.wipeout" "_p" "_last" "_y")
      (princ "\nWipeout erstellt! ")))

 

Just noticed that they've changed the code-window behavior - it's wrapping a text automatically - the code is significantly less readable, imho. 😞

Message 3 of 3

C.Utzinger
Collaborator
Collaborator
Accepted solution

Thank you very much!!!

 

Here my completed code:

 

(defun c:<WipeoutNeu (/ *error* lay cmd ent)

	(defun *error* (errmsg)
    	(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      	   (princ (strcat "\nError: " errmsg)))
    	(command-s "_.undo" "_end")
        (command-s "_.u")
	(setvar 'CLAYER lay)
	(setvar 'CMDECHO cmd)
	(princ "\nAlles rückgängig gemacht! ")
    	(princ))

	(command "_.undo" "_begin")
	(setq lay (getvar 'CLAYER)
              cmd (getvar 'CMDECHO))
	(setvar 'CMDECHO 0)
  	(command "_.-LAYER" "_m" "-I-Wipeout" "_co" "255" "-I-Wipeout" "")
	
  (if (setq ent (car (entsel "\nGeschlossene Polylinie wählen oder <Neue zeichnen>: ")))
    (if (and (= "LWPOLYLINE" (cdr (assoc 0 (entget ent))))
             (= 1 (logand 1 (cdr (assoc 70 (entget ent))))))
      	(progn
        	(command "_.wipeout" "_p" ent "_y")
        	(princ "\nWipeout erstellt! "))
      		(progn 
			(command "_.undo" "_end")
        		(command "_.u")
			(princ "\nFehler: Geschlossene Polylinie erforderlich!")))
        (progn
		(command "_pline" (while (> (getvar "cmdactive") 0) (command pause)))
		(setq ent (entlast))
		(if (and (= "LWPOLYLINE" (cdr (assoc 0 (entget ent))))
             	    	 (= 1 (logand 1 (cdr (assoc 70 (entget ent))))))
      			   (progn
        		   (command "_.wipeout" "_p" ent "_y")
        		   (princ "\nWipeout erstellt! "))	
			   (princ "\nFehler: Geschlossene Polylinie erforderlich!"))))

	(command "_.undo" "_end")
	(setvar 'CLAYER lay)
	(setvar 'CMDECHO cmd)
	(prin1) 
) ; end of defun
0 Likes