zwonko Posted January 23 Posted January 23 I have a problem with the laydel command. I have the following code in AutoLISP: (defun c:dellayers76_only6 ( / hms:LayerList* cla ech lay* laylst LayList cnt) (defun hms:LayerList* (path / LayName TblName TblNameList) (while (setq TblName (tblnext "Layer" (null TblName))) (if (wcmatch (setq LayName (strcase (cdr (assoc 2 TblName)))) (strcase path)) (setq TblNameList (cons LayName TblNameList)) ) ) (acad_strlsort TblNameList) );; hmsLayerList* (if (and (setq lay* "6 *,6_*") (setq LayList (hms:LayerList* lay*))) (progn ;; Filter LayList, to exclude "7 view" i "7_view" (setq LayList (vl-remove-if '(lambda (layer) (member (strcase layer) '("7 VIEW" "7_VIEW"))) LayList)) ;; Add operation on matched layers ; (command "_.-layer" "_U" lay* "_T" lay* "") (command "_.-layer" "_U" lay* "") (setq ech (getvar 'CMDECHO)) ;(setvar 'CMDECHO 0) ; (command "_.undo" "G") (command "_.undo" "M") (setq cla (strcase (getvar 'CLAYER))) (if (member cla LayList) (command "_.-layer" "_U" "0" "_T" "0" "_S" "0" "") ) (foreach l LayList (command "_.-laydel" "_N" l "" "_Y" "") ) (command "_.undo" "E") (setvar 'CMDECHO ech) ) (prompt "\n Layer Name not valid, or no matching layers... ") ) (princ) ) The code is supposed to delete auxiliary layers whose names start with "6". When I use the dellayers76_only6 code and use the regen command, an additional elements appears in the drawing (see the revision cloud in the attached drawing,). The elements that appeared belonged to the layer that was deleted. However, there is no problem with additional elements appearing when I manually call the laydel command in ZWCAD, select the layer, and regenerate the drawing. Does anyone have an idea why this difference occurs? drawing_test2.dwg Quote
pkenewell Posted January 23 Posted January 23 @zwonko The revision cloud in your sample drawing is NOT on the "6 pomoc 01" layer, but is on the "3 przerywana 05", and the color is orerrided to RED. Quote
zwonko Posted January 23 Author Posted January 23 Trying to explain better: When You open sample drawing, use the dellayers76_only6 LISP, regen drawing, You will see that something new shown on revision cloud. When You open sample drawing, manually use command laydel, choose layer "6 pomoc 01", regen, nothing will show in revision cloud. Quote
marko_ribar Posted January 23 Posted January 23 Do you have to use LAYDEL command? There is alternative - unlock desired Layer, erase all from that Layer and finally PURGE that Layer... All procedure could be automatized through LISP... HTH. M.R: Quote
zwonko Posted January 23 Author Posted January 23 If there is another way ok. But with the LAYDEL I'm sure that it will erase entire layer, even if it is in blocks. Quote
mhupp Posted January 24 Posted January 24 (edited) 7 hours ago, zwonko said: I'm sure that it will erase entire layer, even if it is in blocks. if layer's are locked maybe not. and looks like 6 pomoc 01 is also frozen in your example so that's also might be why your lisp isn't working. I try to avoid using command in lisp when you can. idk if ZWCAD can use visual lisp (defun C:dellayers76_only6 (dellay "6") (princ)) (defun dellay (str / doc lst lay del) (vl-load-com) (setq check (getvar "CLAYER")) (while (or (wcmatch check (strcat str " *")) (wcmatch check (strcat str "_*"))) (princ "\nSwitch Current layer") (exit) ) (vla-startundomark (setq Drawing (vla-get-activedocument (vlax-get-acad-object)))) ;set an undo point (setq lst (vla-get-Layers Drawing)) (setq del '()) (vlax-for layer lst (let ((lay (vla-get-Name layer))) (if (or (wcmatch lay (strcat str " *")) (wcmatch lay (strcat str "_*"))) (progn (if (= (vla-get-Lock layer) :vlax-true) (progn (if (= (ACET-UI-MESSAGE (strcat "Do you want to Delete Locked Layer " lay " (Y/N): ") "Locked Layer" (+ Acet:YESNO Acet:ICONWARNING)) 6) (progn (vla-put-Lock layer :vlax-false) ; Unlock the layer (vla-delete layer) ; Then delete (setq del (cons lay del)) ; Add layer name to the del list ) ) ) (vla-delete layer) ;Delete layer (setq del (cons lay del)) ;Add layer name to del list ) ) ) ) ) (vla-endundomark Drawing) (if (eq (setq x (length del) 0)) (princ (strcat "\nNo Layers Found Starting with """ str " *"" or """ str "_*""")) (progn (princ (strcat "\n" x " Layers(s) Deleted")) (princ del) ) ) (princ) ) Edited January 24 by mhupp 1 Quote
zwonko Posted January 24 Author Posted January 24 (edited) Thats the point that zwcad is lack of some autolisp function . @mhuppYour code is not starting I'm getting error: Error: variable must be a symbol - "6" ZWCAD is lack of vla-delete. Also acet-ui-* is propably not working. Thought maybe woraround will be delete every object inside blocks, and outside blocks with simple entdel, before laydel. Edited January 24 by zwonko Quote
zwonko Posted January 24 Author Posted January 24 Okej, found the problem. Now code from first post is working but with following modification: from: (if (wcmatch (setq LayName (strcase (cdr (assoc 2 TblName)))) (strcase path)) to (if (wcmatch (setq LayName (cdr (assoc 2 TblName))) (strcase path)) so the problem was somehow STRCASE. Thanks everybody for replies. 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.