Draw diagonal lines in a rectangel

Status
Not open for further replies.

oje

Usenet Archive
Joined
Dec 3, 2001
Messages
5
Reaction score
0
Hi

I need to draw diagonal lines in a rectangle (draw a cross in a shape).

Anyone know a lisp or vba to do this?

Thanks.

oje
 
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).
 
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).
 
I think I one downloaded a lisp that did this... I found it on CADshack or CAD Depot something like joist.lsp

I don't seem to have it anymore otherwise I would have emailed

Alan

On 10 Dec 2001 04:04:38 -0800, (oje) wrote:

>Hi
>
>I need to draw diagonal lines in a rectangle (draw a cross in a shape).
>
>Anyone know a lisp or vba to do this?
>
>Thanks.
>
>oje

Support for AutoCAD, IntelliCAD & Cadvance Users
Web Site http://www.cadalot.co.uk
TenLinks Site of the Week & Top Ten Listed
 
here's one I use for making shims...draws a rectangle with and "X" in the middle from 3 picked points. I wrote it in '95 while still an amateur so I apologize for the code...but it works. You can eliminate or revise the layer creation part if you like...
Dave

(defun C:SHIM2 (/ svcm svosm svcl svsa lay1 p1 p2 p3 p4) (setq svcm (getvar "cmdecho")) (setq svosm (getvar "osmode")) (setq svcl (getvar "clayer")) (setq svsa (getvar "snapang")) (setvar "cmdecho" 0) (command "OSMODE" "0") (setq lay1 "fast") (if (/= svlay lay1) (command "layer" "m" "fast" "c" "cyan" "" "") ) (graphscr) (initget 1) (setq P1 (getpoint "\nFrom point: ")) (initget 1) (setq P2 (getpoint P1 "\nTo point: ")) (setvar "snapang" (angle P1 P2)) (setvar "orthomode" 1) (initget 1) (setq P3 (getpoint P2 "\nTo point: ")) (setq P4 (polar P3 (angle P2 P1) (distance P2 P1))) (setvar "osmode" 0) (command "_.PLINE" P1 P2 P3 P4 P1 P3 P4 P2 "") (setvar "osmode" svosm) (setvar "cmdecho" svcm) (setvar "clayer" svcl) (setvar "snapang" svsa) (redraw) (princ "done ") (princ) ) ;End "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).
 
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).
 
Hi all

Thanks for your help.

The lispcode works fine.

Regards
oje

"Paul Turvill" wrote:
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)))
...
 
Status
Not open for further replies.

Latest threads

Back
Top