Guest Posted June 16, 2021 Posted June 16, 2021 (edited) Hi. I am using this code to hatch polylines. The problem is when i run the code and hatch the polyline, delete the polyline. Is it possible not to delete the polyline? (defun c:hatchpez (/ *error* v l ss doc) (defun *error* (x) (if v (mapcar 'setvar '(HPNAME CMDECHO) v) ) (if (wcmatch (strcase x) "*BREAK*,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " x " **")) ) ) (setq l (entlast) v (mapcar 'getvar '(HPNAME CMDECHO)) ) (command "_layer" "_m" "ROAD" "c" "2" "" "") (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE")))) (progn (mapcar 'setvar '(HPNAME CMDECHO) '("SOLID" 0)) (vla-startUndomark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) ((lambda (i / sn c o) (while (setq sn (ssname ss (setq i (1+ i)))) (command "_.-hatch" "S" sn "" "TRANSPARENCY" 50 "") (if (not (eq l (setq o (entlast)))) (if (setq c (assoc 62 (entget sn))) (entmod (append (entget o) (list (cons 62 (cdr c))))) (entmod (append (entget o) '((62 . 256)))) ) ) (entdel sn) (setq l o) ) ) -1 ) (vla-Endundomark doc) ) ) (*error* nil) ;layer 0 (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1)) (princ) ) ; end defun (vl-load-com) Thanks Edited June 16, 2021 by prodromosm Quote
Tharwat Posted June 16, 2021 Posted June 16, 2021 Comment or remove this (entdel sn) from the routine. Quote
tombu Posted June 16, 2021 Posted June 16, 2021 Place a ; semicolon in front of (entdel sn) to comment it out, then reload the saved lisp before trying it again. Quote
ammobake Posted June 16, 2021 Posted June 16, 2021 From what I was reading earlier ssget doesn't always play nice with entdel anyway. Out of curiosity, after deleting "entdel sn" does the routine work in model and paper space? -ChriS 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.