1. Login to Give a bone

## Polyline Coordinates finding

Dear All,

How r u?

pls. find attached rectangle at any rotation and its point p1, p2, p3, and p4.

select this rectangle and get its coordinates and then find the points (p1, p2, p3, p4)

p1 = min X
p2 = Max Y
p3 = Max y
p4 = min X

This is done in AutoLISP and create points perfectly. But I want to convert in VBA and I want to create standalone application in VB6.

can anyone help me.

after selecting the box and using coordinates find the p1, p2, p3, and p4 points.

Avinash

2. Login to Give a bone

## Re: Polyline Coordinates finding

Hi,

help me to out from this problem.

for further clarification I am submitting my Code in AutoLSIP form.

Code:
(defun RP1 () ; (/ ENT ELST PTS SS1 OLDOSM INS OBJ PT1 P1 P2 P3 P4)
(setvar "cmdecho" 0)
(setq OLDOSM (getvar "osmode"))
(if
(and (setq ENT
(car (entsel "\n Select a Rectangle or 4 Sides Polygon: "))
)
(eq (cdadr (setq ELST (entget ent))) "LWPOLYLINE")
)
(progn
(foreach item ELST
(if (eq (car item) 10)
(setq pts (cons (cdr item) PTS))
)
)
(setq P1 (car PTS))
;(command "text" "justify" "MC" P1 "10" "0" "P1")
;(command "text" "justify" "MC" P3 "10" "0" "P3")
;(command "text" "justify" "MC" P2 "10" "0" "P2")
;(command "text" "justify" "MC" P4 "10" "0" "P4")
;(command "select" "wp" P1 P2 p3 p4 "" "")
)
)
(if (null ENT)
(progn
(princ "\nERROR: Nothing selected.")
(command "_.layer" "On" "C" "") ; Reset command echoing
(command "_.layer" "On" "H" "")
(exit)
)
)
(setq flt '((-4 . "<OR")
(0 . "CIRCLE")
(-4 . "OR>")
)
)
(setq flt1 '((-4 . "<OR")
(0 . "LINE")
(-4 . "OR>")
(8 . "C")
)
)
(setq ss (ssget "Wp" (list p1 p2 p3 p4)))
(setq SsC (ssget "p" flt))
(setq ss1 (ssget "Wp" (list p1 p2 p3 p4))) ;dme1 sspnt67))
(setq SsC1 (ssget "p" flt1))
(setvar "osmode" OLDOSM)
(princ)
(setq ent1 (ssname ssc 0))
(setq opp (entget ent1))
(setq opp1 (assoc 10 opp))

(setq SsC (bns_esort SsC
'((e1) (car (cdr (assoc 10 e1))))
;quoted function for x
)
) ;setq
(setq sslen (sslength SsC))
(setq sslentemp (sslength SsC))
(setq c1 0)

(setq crcl0 (ssname SsC 0))
(setq crcl1 (entget crcl0))
(setq cdstx1 (cadr (assoc 10 crcl1)))
(setq cdsty1 (caddr (assoc 10 crcl1)))
(setq crcl00 (ssname SsC (- sslen 1)))
(setq crcl2 (entget crcl00))
(setq cdstx2 (cadr (assoc 10 crcl2)))
(setq cdsty2 (caddr (assoc 10 crcl2)))
(setq
cirang (* (/ (angle (list cdstx1 cdsty1) (list cdstx2 cdsty2)) pi)
180.0
)
)

(if (or (> cirang 270) (< cirang 360));if two circles angle 90 to 180 degree
(progn
(setq xt2 (max (car p1) (car p2) (car p3) (car p4))) ;max X
(setq xt4 (min (car p1) (car p2) (car p3) (car p4))) ;min X

(if (member xt1 (nth 0 pts))
(setq P1 (car PTS))
)
(if (member xt2 (nth 0 pts))
(setq P2 (car PTS))
)
(if (member xt3 (nth 0 pts))
(setq P3 (car PTS))
)
(if (member xt4 (nth 0 pts))
(setq P4 (car PTS))
)

(if (member xt1 (nth 1 pts))
)
(if (member xt2 (nth 1 pts))
)
(if (member xt3 (nth 1 pts))
)
(if (member xt4 (nth 1 pts))
)

(if (member xt1 (nth 2 pts))
)
(if (member xt2 (nth 2 pts))
)
(if (member xt3 (nth 2 pts))
)
(if (member xt4 (nth 2 pts))
)

(if (member xt1 (nth 3 pts))
)
(if (member xt2 (nth 3 pts))
)
(if (member xt3 (nth 3 pts))
)
(if (member xt4 (nth 3 pts))
)
) ;end progn
) ;end if

(if (< cirang 90) ;if two circles angle 0 to 90 degree
(progn
(setq xt1 (min (car p1) (car p2) (car p3) (car p4)))
(setq xt3 (max (car p1) (car p2) (car p3) (car p4)))

(if (member xt1 (nth 0 pts))
(setq P1 (car PTS))
)
(if (member xt2 (nth 0 pts))
(setq P2 (car PTS))
)
(if (member xt3 (nth 0 pts))
(setq P3 (car PTS))
)
(if (member xt4 (nth 0 pts))
(setq P4 (car PTS))
)

(if (member xt1 (nth 1 pts))
)
(if (member xt2 (nth 1 pts))
)
(if (member xt3 (nth 1 pts))
)
(if (member xt4 (nth 1 pts))
)

(if (member xt1 (nth 2 pts))
)
(if (member xt2 (nth 2 pts))
)
(if (member xt3 (nth 2 pts))
)
(if (member xt4 (nth 2 pts))
)

(if (member xt1 (nth 3 pts))
)
(if (member xt2 (nth 3 pts))
)
(if (member xt3 (nth 3 pts))
)
(if (member xt4 (nth 3 pts))
)
) ;end progn
) ;end if

(command "text" "justify" "MC" P1 "10" "0" "P1")
(command "text" "justify" "MC" P3 "10" "0" "P3")
(command "text" "justify" "MC" P2 "10" "0" "P2")
(command "text" "justify" "MC" P4 "10" "0" "P4")

)

thanks,

Avinash

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•