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
3,061 Views
7 Replies
Message 1 of 8

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

Anonymous
Not applicable

Could somebody help me with this simple routine:

1. Select all hatches with pattern SOLID
2. Generate boundary for them (_.hatchgenerateboundary)
3. Change the colour of this boundary to green.

Thanks!

0 Likes
Accepted solutions (1)
3,062 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

(defun c:R2 ( / ss en ht hs)
(if (setq ss (ssget "_X" '((0 . "HATCH") (2 . "SOLID"))))
(command "_.hatchgenerateboundary" ss ""))
(princ)
)

0 Likes
Message 3 of 8

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

(defun c:R2 ( / ss en ht hs)
(if (setq ss (ssget "_X" '((0 . "HATCH") (2 . "SOLID"))))
(command "_.hatchgenerateboundary" ss ""))
(princ)
)


Almost done...

 

(defun c:R2 ( / ss)
  (if (setq ss (ssget "_X" '((0 . "HATCH") (2 . "SOLID"))))
    (command "_.hatchgenerateboundary" ss ""
	     "_.chprop" ss "" "_C" 3 ""))
    (princ)
)
0 Likes
Message 4 of 8

Anonymous
Not applicable

Thank you for your help again.

Maybe I didn't express myself clearly, but I wanted to change the colour of the line to green, not the colour of the SOLID 🙂

And one more thing, can we add a third condition for the selection - 1) HATCH, 2) PATTERN "SOLID", 3) COLOUR "CYAN"

0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

What layer to use?
hatchgenerateboundary creates a boundary in current layer...

 

Color cyan assigned to object only, or to a layer of hatch (color by layer)?

0 Likes
Message 6 of 8

Anonymous
Not applicable

Layer name "Reinforcement" (existing layer), but with colour of the boundary - green.

Layer CYAN to be in the selection criteria.
(if (setq ss (ssget "_X" '((0 . "HATCH") (2 . "SOLID") ?(COLOUR "CYAN"))))

 

 

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok... try this. Because of layer I has to go thru selections set.

 

(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")
)
Message 8 of 8

Anonymous
Not applicable

* Nevermind 🙂

0 Likes