Lisp to draw a 3 point rectangle and hatch with the given angle

Lisp to draw a 3 point rectangle and hatch with the given angle

francine.zimmermannSRSWJ
Advocate Advocate
726 Views
12 Replies
Message 1 of 13

Lisp to draw a 3 point rectangle and hatch with the given angle

francine.zimmermannSRSWJ
Advocate
Advocate

I found a Lisp on Internet to draw a rectangle by given 2 point and a thickness dimension.

On that Lisp I add a command line to make a Hatch. It works, apart from the angle which is not taken into account.
Can anyone help me please?

0 Likes
727 Views
12 Replies
Replies (12)
Message 2 of 13

Kent1Cooper
Consultant
Consultant

The command-line usage of the Hatch command wants input for the rotation in degrees, but the 'ang' variable is in radians.  So:

....

(command "-hatch" "S" "L" "" "P" "Brick" RW* (cvunit ang "radian" "degree") "" "")

....

Kent Cooper, AIA
Message 3 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

The angle is now working but the hatch is not oriented along the line but is rotated by 90°.

How can I adjust that?

 

0 Likes
Message 4 of 13

ВeekeeCZ
Consultant
Consultant

Add it?

(cvunit (+ ang (/ pi 2)) "radian" "degree")

Message 5 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

I tested it, now it is working.

I have an other request, is it possible to set the hatch origin on the line P1 P2?

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

Just run the -hatch command and follow the prompts. There is the "Origin" option, so to answer your question, yes, it is.

0 Likes
Message 7 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

Yes I know that I can redefine the origin but is it not possible to do it directly in the lisp.

It's restrictive if each time I hatch I have to redefine the origin, knowing that line P1 P2 is given

francinezimmermannSRSWJ_0-1729156580568.png

 

 

 

0 Likes
Message 8 of 13

ВeekeeCZ
Consultant
Consultant

@francine.zimmermannSRSWJ 

 

what I meant was to run (type) the command, see what options or key letters need to be typed, and then fill them into your script line...

 

(command "-hatch" "S" "L" "" "P" "Brick" RW* (cvunit ang "radian" "degree") "_O" "_S" ... "" "")

 

It's not a rocket science.

 

Message 9 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

ok I understand

(command "-hatch" "S" "L" "" "P" "INSULATION_" RW* (cvunit (+ ang (/ pi 2)) "radian" "degree") "O" "S" P1 "" "")

 

0 Likes
Message 10 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

I have a last question : is it possible by stretching the thickness of the rectangle the hatch will be adjust automatically? Like with a dynamic block?

francinezimmermannSRSWJ_0-1729159241554.png

 

0 Likes
Message 11 of 13

ВeekeeCZ
Consultant
Consultant

If you have HPASSOC 1 and HPDRAWORDER 3 or 1 it should work that way.

0 Likes
Message 12 of 13

francine.zimmermannSRSWJ
Advocate
Advocate

I have those variable like what you have written. It change the hatch contour but I was meaning the hatch scale

francinezimmermannSRSWJ_0-1729166246073.png

 

0 Likes
Message 13 of 13

Sea-Haven
Mentor
Mentor

Because a hatch is a repeating pattern you have say the height fixed then it will repeat the pattern, yes you are correct you could change the height via new scale. But it will increase the X spacing.  I have a different way to do this using a pline and the code asks for height so in this case I would erase and create again. Sorry copyrighted no code, but happy to help if you want to have a go, otherwise google "Insulation Autocad lisp"

SeaHaven_0-1729207048326.png

 

 

0 Likes