PDA

View Full Version : Get the top most left corner & bottom right corner point of a closed Polyline



KHADREE_SHARIFF
2007-04-07, 06:20 AM
how to get the top most left corner & bottom right corner point of a closed polyline
created by using boundary command,
how to get the values form the entget
list and that gave me another ? if i want to use the assoc 10 value of a
polyline how do i repeat so that the list will give me the second assoc 10 value

Command: !ed2 ((-1 . <Entity name: 7dda44d0>) (0 . "LWPOLYLINE") (330 . <Entity
name: 7dde6cf8>) (5 . "332A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8
. "S-Rein") (100 . "AcDbPolyline") (90 . 11) (70 . 1) (43 . 0.0) (38 . 0.0) (39
. 0.0) (10 5311.13 5828.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 5311.13
6128.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 646.43 6128.44) (40 . 0.0) (41 .
0.0) (42 . 0.0) (10 646.43 5828.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10
646.583 2298.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 646.43 2298.44) (40 .
0.0) (41 . 0.0) (42 . 0.0) (10 646.43 1998.44) (40 . 0.0) (41 . 0.0) (42 . 0.0)
(10 5310.41 1998.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 5310.41 2298.44) (40
. 0.0) (41 . 0.0) (42 . 0.0) (10 5310.43 2298.44) (40 . 0.0) (41 . 0.0) (42 .
0.0) (10 5310.43 5828.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

as you can see there are more 10 values listed so my question is
would be how do you use the first 10 and then the second 10 and then the third 10
( see image file)

CAB2k
2007-04-07, 01:54 PM
;following by Tony Tanzillo
(list
(apply 'mapcar (cons 'min ptlst))
(apply 'mapcar (cons 'max ptlst))
)

ravishh
2007-04-08, 11:10 AM
Even I am finding it difficult to get the 2nd, 3rd, etc... points i.e. I tried CAB2k suggestion, but not able to understand working.
Ravish

CAB2k
2007-04-08, 12:28 PM
I thought you wanted the Lower left & uper right of the point. That was part od the solution.
But if its the bounding box you want use this:

(defun c:test (/ ent obj ll lr ur ul)
(setq ent (car (entsel)))
(setq obj (vlax-ename->vla-object ent))
(vla-getboundingbox obj 'll 'ur)
(setq ll (vlax-safearray->list ll))
(setq ur (vlax-safearray->list ur))
(setq ul (list (car ur)(cadr ll)))
(setq lr (list (car ll)(cadr ur)))
(grvecs (list -256 ll lr lr ur ur ul ul ll))
(princ)
)

CAB2k
2007-04-08, 12:45 PM
If its the point list you want to work with, perhaps this will do:

(defun c:test (/ elst ll lr ur ul)

(setq elst
'((-1 . <Entityname:7dda44d0>) (0 . "LWPOLYLINE") (330 . <Entityname:7dde6cf8>)
(5 . "332A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "S-Rein")
(100 . "AcDbPolyline") (90 . 11) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0)
(10 5311.13 5828.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 5311.13 6128.44)
(40 . 0.0) (41 . 0.0) (42 . 0.0) (10 646.43 6128.44) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (10 646.43 5828.44) (40 . 0.0) (41 . 0.0) (42 . 0.0)
(10 646.583 2298.44)(40 . 0.0) (41 . 0.0) (42 . 0.0) (10 646.43 2298.44)
(40 . 0.0) (41 . 0.0) (42 . 0.0) (10 646.43 1998.44) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (10 5310.41 1998.44) (40 . 0.0) (41 . 0.0) (42 . 0.0)
(10 5310.41 2298.44) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 5310.43 2298.44)
(40 . 0.0) (41 . 0.0) (42 . 0.0) (10 5310.43 5828.44) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (210 0.0 0.0 1.0))
)

(setq ptlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst)))

(setq ll (apply 'mapcar (cons 'min ptlst))
ur (apply 'mapcar (cons 'max ptlst))
ul (list (car ur)(cadr ll))
lr (list (car ll)(cadr ur))
)

(mapcar 'print (list ll lr ur ul))
(princ)
)