Simple Lisp for Cross lines between rectangle.

Simple Lisp for Cross lines between rectangle.

zaid.k3112
Contributor Contributor
4,485 Views
23 Replies
Message 1 of 24

Simple Lisp for Cross lines between rectangle.

zaid.k3112
Contributor
Contributor

Hello, I need a simple lisp which lets me select a 2 points i.e. a rectangle in which it will make cross lines in a desired layer with line type. 

0 Likes
Accepted solutions (1)
4,486 Views
23 Replies
Replies (23)
Message 21 of 24

john.uhden
Mentor
Mentor

@ronjonp 

No crucifixion, but I disagree.

Without the dummy command, and because there is no use of the (command) function elsewhere, you get this...

CrissCross v1.0 (c)2022, John F. Uhden
Seclect rectangles...
Select objects: Specify opposite corner: 3 found

Select objects:

Command:
Command:

 

i.e. a double "Command:"

I always include it by copying and pasting from another program 'cause I may not know yet if I will be using a (command) function.  It doesn't hurt anything and it's all within an undo group.

 

Oh, and BTW, the variables do get reset...

(defun *error* (error)
(mapcar 'setvar vars vals)
(vla-endundomark *doc*)
(cond
((not error))
((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
(1 (princ (strcat "\nERROR: " error)))
)
(princ)
)

John F. Uhden

0 Likes
Message 22 of 24

ronjonp
Mentor
Mentor

@john.uhden I could have sworn last night that those vars were not being reset .. my bad 😲.

 

Anyhoo ... the dummy command still baffles me. I ran your code with and without and the prompts were identical.

Command: CRISSCROSS
CrissCross v1.0 (c)2022, John F. Uhden
Select rectangles...
Select objects: 1 found
Select objects:
Command:

Command: CRISSCROSS
CrissCross v1.0 (c)2022, John F. Uhden
Select rectangles...
Select objects: 1 found
Select objects:
Command:

Happy Friday!

 

Message 23 of 24

calderg1000
Mentor
Mentor

Regards @zaid.k3112 

Maybe this code can help you

 

(defun c:Mirrline (/ p1 p2 m1 m2)
  (vl-cmdf "Layer" "s" "02-Steps" "Ltype" "Dash Dash 1" "" "") 
  (setq p1 (getpoint "\nP1: ")
        p2 (getpoint p1 "\nP1: ")
  )
  (vl-cmdf "pline" p1 p2 "")
  (vl-cmdf "chprop" (entlast) "" "S" 0.01 "")
  (setq m1 (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5 0.))
        m2 (mapcar '+ m1 '(0. 1. 0.))
  )
  (vl-cmdf "mirror" (entlast) "" "none" m1 "none" m2 "n")
  (vl-cmdf "chprop" (entlast) "" "S" 0.01 "")
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 24 of 24

Kent1Cooper
Consultant
Consultant

@calderg1000 wrote:

Maybe this code can help you


Just be aware that this will work as expected if the rectangular area that you pick opposite corners of to put an X in is orthogonally oriented.  It will give incorrect results if it's at any non-orthogonal angle:

Kent1Cooper_0-1650283127526.png

That's where routines that involve selecting a Polyline rectangle [when you can], or even a non-rectangular 4-sided closed Polyline such as a trapezoid, and use its vertices to draw the X, have an advantage.

 

[And, of course, edit the Layer name, linetype and scale factor to suit your needs.]

Kent Cooper, AIA
0 Likes