Results 1 to 2 of 2

Thread: Polyline Coordinates finding

  1. #1
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    147
    Login to Give a bone
    0

    Default 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.

    Thanks in Advance.

    Avinash
    Attached Images Attached Images

  2. #2
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    147
    Login to Give a bone
    0

    Default 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")
    (setq P3 (caddr PTS))
    ;(command "text" "justify" "MC" P3 "10" "0" "P3")
    (setq P2 (cadr PTS))
    ;(command "text" "justify" "MC" P2 "10" "0" "P2")
    (setq P4 (cadddr PTS))
    ;(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 xt1 (max (cadr p1) (cadr p2) (cadr p3) (cadr p4))) ;max Y
    (setq xt2 (max (car p1) (car p2) (car p3) (car p4))) ;max X
    (setq xt3 (min (cadr p1) (cadr p2) (cadr p3) (cadr p4))) ;min Y)
    (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))
    (setq P1 (cadr PTS))
    )
    (if (member xt2 (nth 1 pts))
    (setq P2 (cadr PTS))
    )
    (if (member xt3 (nth 1 pts))
    (setq P3 (cadr PTS))
    )
    (if (member xt4 (nth 1 pts))
    (setq P4 (cadr PTS))
    )

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

    (if (member xt1 (nth 3 pts))
    (setq P1 (cadddr PTS))
    )
    (if (member xt2 (nth 3 pts))
    (setq P2 (cadddr PTS))
    )
    (if (member xt3 (nth 3 pts))
    (setq P3 (cadddr PTS))
    )
    (if (member xt4 (nth 3 pts))
    (setq P4 (cadddr 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 xt2 (max (cadr p1) (cadr p2) (cadr p3) (cadr p4)))
    (setq xt3 (max (car p1) (car p2) (car p3) (car p4)))
    (setq xt4 (min (cadr p1) (cadr p2) (cadr p3) (cadr 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))
    (setq P1 (cadr PTS))
    )
    (if (member xt2 (nth 1 pts))
    (setq P2 (cadr PTS))
    )
    (if (member xt3 (nth 1 pts))
    (setq P3 (cadr PTS))
    )
    (if (member xt4 (nth 1 pts))
    (setq P4 (cadr PTS))
    )

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

    (if (member xt1 (nth 3 pts))
    (setq P1 (cadddr PTS))
    )
    (if (member xt2 (nth 3 pts))
    (setq P2 (cadddr PTS))
    )
    (if (member xt3 (nth 3 pts))
    (setq P3 (cadddr PTS))
    )
    (if (member xt4 (nth 3 pts))
    (setq P4 (cadddr 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

Similar Threads

  1. AB118-3: Finding Your Way Around Shared Coordinates
    By Autodesk University in forum Architecture and Building Design
    Replies: 0
    Last Post: 2014-11-30, 01:21 PM
  2. Replies: 0
    Last Post: 2014-11-13, 11:02 PM
  3. 2011: Finding Coordinates in the Revit DB Link SQL Database
    By kdane in forum Revit Structure - General
    Replies: 1
    Last Post: 2011-10-05, 02:57 AM
  4. finding x y coordinates
    By rwbaker54 in forum VBA/COM Interop
    Replies: 3
    Last Post: 2008-04-08, 05:40 PM

Posting Permissions

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