Try these for starters. If they don't do just what you want, feel free to modify:
;; Simple version uses (command) function and
;; constructs the figure with PLINE and LINE
;; objects:
(defun C:REX (/ p1 p2 p3 p4)
(command "_.undo" "_be")
(setq p1 (getpoint "\nLower left corner: ")
p3 (getpoint p1 "\nUpper right corner: ")
p2 (list (car p3)(cadr p1))
p4 (list (car p1)(cadr p3)))
(command "_.pline" p1 p2 p3 p4 "_c"
"_.line" p1 p3 ""
"_.line" p2 p4 ""
"_.undo" "_e")
(princ)
)
;; This version uses no (command) functions; it
;; constructs the figures with LINE objects
;; created with (entmake):
(defun c:REX1 (/ p1 p2 p3 p4)
(command "_.undo" "_be")
(setq p1 (getpoint "\nLower left corner: ")
p3 (getpoint p1 "\nUpper right corner: ")
p2 (list (car p3)(cadr p1))
p4 (list (car p1)(cadr p3)))
(do p1 p2)
(do p2 p3)
(do p3 p4)
(do p4 p1)
(do p1 p3)
(do p2 p4)
(command "_.undo" "_e")
(princ)
)
(defun do (p q)
(entmake
(list
'(0 . "LINE")
(cons 10 p)
(cons 11 q)))
)
;; Finally, this version creates an LWPOLYLINE
;; for the rectangle, and LINE objects for the
;; "X" again using nothing but (entmake):
(defun c:REX2 (/ p1 p2 p3 p4)
(command "_.undo" "_be")
(setq p1 (getpoint "\nLower left corner: ")
p3 (getpoint p1 "\nUpper right corner: ")
p2 (list (car p3)(cadr p1))
p4 (list (car p1)(cadr p3)))
(entmake
(list
'(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(90 . 4)
'(70 . 129)
(cons 10 p1)
(cons 10 p2)
(cons 10 p3)
(cons 10 p4)))
(entmake
(list
'(0 . "LINE")
(cons 10 p1)
(cons 11 p3)))
(entmake
(list
'(0 . "LINE")
(cons 10 p2)
(cons 11 p4)))
(command "_.undo" "_e")
(princ)
)
"oje" wrote:
I would like to be able to do both.
oje
"Paul Turvill" wrote:
...
> Existing rectangle, or do you want to draw the whole thing (with
diagonals)
> at one time?
> ___
>
> "oje" wrote:
>
> >
> > I need to draw diagonal lines in a rectangle (draw a cross in a
shape).