PDA

View Full Version : Find the lower left corner of polyline rectangle



avinash00002002
2007-04-27, 09:26 AM
I have a rectangle which is made from polyline. If I select the rectangle by using (ssget).

How can I get lower left corner of rectangle. Can anyone solve this probs.



Thnx

Avinash

Avatart
2007-04-27, 10:23 AM
I have a rectangle which is made from polyline. If I select the rectangle by using (ssget).

How can I get lower left corner of rectangle. Can anyone solve this probs.



Thnx

AvinashThe way I would approach this is to find the DXF co-ordinate values and interrogate them for the smallest X value and the smallest Y value, whichever has these values is your bottom left corner.

CADmium
2007-04-27, 11:32 AM
(defun C:LowerLeftCorner(/ OBJ P1 P2)
(if(and(setq OBJ(car(entsel "\nSelect PL:")))
(setq OBJ(vlax-ename->vla-object OBJ))
)
(progn
(vla-getboundingbox OBJ 'P1 'P2)
(setq P1(vlax-safearray->list P1))
(alert (strcat"Lower-Left-Corner : "(vl-princ-to-string P1)))
)
)
)

kennet.sjoberg
2007-04-27, 11:33 AM
In WCS or UCS ?

: ) Happy Computing !

kennet

avinash00002002
2007-04-28, 08:10 AM
If my rectangle is rotated at any angle. then?

kpblc2000
2007-04-28, 08:52 AM
Try this:

(defun test (/ ent lst elevation normal res)
(if (and (not (vl-catch-all-error-p
(vl-catch-all-apply
'(lambda () (setq ent (car (entsel "\nSelect polyline"))))
) ;_ end of vl-catch-all-apply
) ;_ end of vl-catch-all-error-p
) ;_ end of not
ent
(= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
) ;_ end of and
(progn
;; Code imported from
;; http://www.autocad.ru/cgi-bin/f1/board.cgi?t=26461HC
(setq elevation (cdr (assoc 38 (entget ent)))
normal (cdr (assoc 210 (entget ent)))
) ;_ end of setq
(if (not elevation)
(setq elevation 0.)
) ;_ end of if
(setq lst
(mapcar
'(lambda (x) (trans (list (cadr x) (caddr x) elevation) normal 0))
(vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))
) ;_ end of mapcar
lst (list (apply 'min (mapcar 'car lst))
(apply 'min (mapcar 'cadr lst))
(apply 'min (mapcar 'caddr lst))
) ;_ end of list
res (list (cons "wcs" lst)
(cons "ocs" (trans lst 0 ent))
(cons "normal" normal)
) ;_ end of list
) ;_ end of setq
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
Control:

((lambda (/ lst)
(setq lst (test))
(entmakex (list (cons 0 "POINT")
(cons 10 (cdr (assoc "wcs" lst)))
(cons 210 (cdr (assoc "normal" lst)))
) ;_ end of list
) ;_ end of entmakex
) ;_ end of lambda
)