Code Red > AutoLISP (Vanilla / Visual)
Draw diagonal hatch lines in rectangle by pick
Christina:
Hello
Searched for a long time, but not found how I know the four points of a rectangle/square to draw diagonal hatch lines by clicking(pick) somewhere in the rectangle.
The rectangle is made by lines and corners are normally 90°.
If someone can give me a hint how to know the points of the corners by picking anywhere in the rectangle, I will search further to draw the diagonals hatch lines!
I want to thank you in advance for reading this!
I have attach example
Christina
ronjonp:
Welcome to TheSwamp! Here's an example with some comments:
--- Code - Auto/Visual Lisp: ---(defun c:foo (/ _boundary e p) ;; RJP » 2021-04-14 ;; Function to get a boundary from a point (bpoly) locks up my session for some reason (defun _boundary (p / e) (setq e (entlast)) (command "_.-boundary" p "") (if (not (equal e (entlast))) (entlast) ) ) ;; If we have a point and a boundary is created (cond ((and (setq p (getpoint "\nPick an internal point: ")) (setq e (_boundary p))) (if (= "SOLID" (cdr (assoc 0 (entget e)))) (alert "Change boundary type to polyline then run the code again...") (progn ;; Get the polyline coordinates (setq p (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget e)))) ;; Remove our temp boundary (entdel e) ;; Create a line using the first and third point (entmakex (list '(0 . "line") (cons 10 (car p)) (cons 11 (caddr p)))) ;; Create a line using the second and fourth point (entmakex (list '(0 . "line") (cons 10 (cadr p)) (cons 11 (cadddr p)))) ) ) ) ) (princ))
Christina:
OMG - Thank you very much ronjonp! :smitten:
My day can not be ruined
Christina
ronjonp:
--- Quote from: Christina on April 14, 2021, 10:42:46 AM ---OMG - Thank you very much ronjonp! :smitten:
My day can not be ruined
Christina
--- End quote ---
Glad to help :)
Christina:
RonJon,
Don't know if I can ask another question, but that's the last one! :oops:
After pick the rectangle, Lisp asks how many divisions I want on the longest side.
If I type 3 the code divides the rectangle into 3 parts and draws diagonal lines in the 3 parts...
Thanks again for your previous code(very happy)!
Christina
Navigation
[0] Message Index
[#] Next page
Go to full version