extract rectangle points

Discussion in 'AutoCAD' started by stephen4444, Sep 17, 2004.

  1. stephen4444

    stephen4444 Guest

    This is what I had in mind

    (this could be a wish list where like the circle when you select the circle the grip show up in the center, for the rectangle the midpoint shows up)


    (DEFUN C:MREC ();MOVE RECTANGEL TO RECTANGLE
    (setq ENT (car (entsel "\n Select First Rectangle to Move: ")))
    (setq ELST (entget ENT))
    (setq NAME (cdr (assoc 0 ELST)))
    (if (/= NAME "LWPOLYLINE")(progn (alert "Not a Rectangle !!!!")(exit)))

    (setq ENT2 (car (entsel "\n To Second Rectangle: ")))
    (setq ELST2 (entget ENT2))
    (setq NAME2 (cdr (assoc 0 ELST2)))
    (if (/= NAME2 "LWPOLYLINE")(progn (alert "Not a Rectangle !!!!")(exit)))

    (setq oldosmode (getvar "osmode"))
    (if (and (= NAME "LWPOLYLINE")(= NAME2 "LWPOLYLINE"))
    (progn
    (setvar "osmode" 0)
    (foreach item ELST
    (if (eq (car item) 10)
    (setq PTS (cons (cdr item) PTS))))
    (setq P1 (car PTS))
    (setq P3 (caddr PTS))
    (setq P2 (cadr PTS))
    (setq P4 (last PTS))
    (setq P5 (list (/ (+ (car P1) (car P3)) 2)(/ (+ (cadr P1) (cadr P3)) 2)))


    (foreach item ELST2
    (if (eq (car item) 10)
    (setq PTS2 (cons (cdr item) PTS2))))
    (setq P6 (car PTS2))
    (setq P7 (caddr PTS2))
    (setq P8 (cadr PTS2))
    (setq P9 (last PTS2))
    (setq P10 (list (/ (+ (car P6) (car P7)) 2)(/ (+ (cadr P6) (cadr P7)) 2)))

    (grdraw p5 p10 11 1)
    (COMMAND "MOVE" ENT "" P5 P10)
    ))
    (setvar "osmode" oldosmode)
    (princ))
     
    stephen4444, Sep 23, 2004
    #21
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.