Lisp for selecting all hatches type solid and generating boundary for them.

Lisp for selecting all hatches type solid and generating boundary for them.

Anonymous
Not applicable
1,273 Views
5 Replies
Message 1 of 6

Lisp for selecting all hatches type solid and generating boundary for them.

Anonymous
Not applicable

how can i generate multiple hatch boundary in a drawing. i need a lisp related to this kind of work.

0 Likes
1,274 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Hi man, I remember you from your PM with same request... I hope that THIS LINK helps you this time to make your first lisp program! Good luck!

 

 

The body of the code is still the same and pretty easy:

(command "_.hatchgenerateboundary" (ssget "_A" '((0 . "HATCH") (2 . "SOLID"))) "")

 

Message 3 of 6

Anonymous
Not applicable

can i get full lisp file please.

0 Likes
Message 4 of 6

Anonymous
Not applicable

where do i put your code in this lisp.

 

(defun c:R2 ( / *error* nVAR oVAR adoc ss en)

(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
(princ (strcat "\nError: " errmsg)))
(mapcar 'setvar nVAR oVAR)
(vla-endundomark adoc)
(princ))

(vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
(setq oVAR (mapcar 'getvar (setq nVAR '(CMDECHO CECOLOR))))
(mapcar 'setvar nVAR '(0 "3"))

(if (setq ss (ssget "_X" '((0 . "HATCH") (2 . "SOLID") (62 . 4))))
(repeat (setq i (sslength ss))
(setq en (ssname ss (setq i (1- i))))
(command "_.HATCHGENERATEBOUNDARY" en ""
"_.CHPROP" "_L" "" "_LA" (cdr (assoc 8 (entget en))) "")))
(*error* "end")
)

0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant

Did you try to copy-paste the code in the command-line and see what you got? Is that the result you need?

 

If so, follow the previous link -- all you need to is add the (defun c:Name () TheBodyI'veGaveYouBefore (princ)) and you're done. 

Message 6 of 6

Anonymous
Not applicable
(defun c:hgb()
  (command "_.hatchgenerateboundary" (ssget "_A" '((0 . "HATCH") (2 . "SOLID"))) "")
  (princ)
  )

Many thanks. Now i know how to create a lisp.

0 Likes