Rectangle with associative hatch LISP

Rectangle with associative hatch LISP

vcostantino
Explorer Explorer
1,256 Views
1 Reply
Message 1 of 2

Rectangle with associative hatch LISP

vcostantino
Explorer
Explorer

How do I draw rectangle offset 1" outside and make hatch associative.

 

this is what i have so far:

 

(defun C:PZ (); Protected Zone
(setq pnt1 (getpoint "Select upper left hand corner for placement of rectangle: "))
(setq pnt2 (getcorner pnt1 "Select lower right hand corner for placement of rectangle: "))
(command "rectangle" pnt1 pnt2)
(setq ent1 (entlast))
(command "-hatch" "P" "ANSI31" "25" "0" "S" ent1"" "")
)

0 Likes
Accepted solutions (1)
1,257 Views
1 Reply
Reply (1)
Message 2 of 2

Kent1Cooper
Consultant
Consultant
Accepted solution

The BHATCH [rather than HATCH] command has a way to set Associativity.  Here's a quickie that uses it, and does the Offset you mention:

 

(defun C:PZ (); Protected Zone
  (setq
    pnt1 (getpoint "Select corner of rectangle: ")
    pnt2 (getcorner pnt1 "Select opposite corner of rectangle: ")
  )
  (command
    "_.rectang" pnt1 pnt2
    "_.offset" 1.0 pnt2 (polar pnt2 (angle pnt1 pnt2) 1) ""
    "_.bhatch" "_advanced" "_associativity" "_yes" "" "_select" "_last" "" ""
  )
)

 

Note that it doesn't require specific corners, but you can pick any two opposite corners in either order [in the case of a Rectangle, it's easy to get an Offset command to use a point known to be outside it, regardless of the direction in which it was drawn -- this is not  necessarily easy for just any Polyline].

 

I'll let you add in further options for pattern name, scale, etc., or you can preset those [and also the associativity, for that matter] with (setvar) functions.

Kent Cooper, AIA
0 Likes