Jump to content

Recommended Posts

Posted (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 by prodromosm
Posted

Place a ; semicolon in front of (entdel sn) to comment it out, then reload the saved lisp before trying it again.

Posted

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

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...