Jump to content

Center Point of Polar Array


eimimitu

Recommended Posts

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • rlx

    8

  • eimimitu

    6

  • Grrr

    5

  • Roy_043

    3

Top Posters In This Topic

Posted Images

I am attaching my solution below as it is different from what Lee has come up with. But keep in mind that both pieces of code return the center in block space coordinates. If the array is moved, rotated, scaled etc. the point will no longer match WCS coordinates. You can use Gile's excellent matrix code to translate it.

 

; (KGA_Sys_ArrayPolarCenter (car (entsel)))
(defun KGA_Sys_ArrayPolarCenter (enm / elst pt)
 (if
   (and
     (setq elst (entget enm))
     (vl-position '(0 . "INSERT") elst)
     (wcmatch (cdr (assoc 2 elst)) "`*[uu]*")
     (setq elst (cdr (member '(102 . "{ACAD_REACTORS") elst)))
     (= (caar elst) 330)
     (setq elst (entget (cdar elst)))
     (vl-position '(0 . "ACDBASSOCDEPENDENCY") elst) ; Required?
     (setq elst (entget (cdr (assoc 330 elst))))
     (vl-position '(0 . "ACDBASSOCACTION") elst) ; Required?
     (vl-position '(1 . "Radius") elst) ; Polar check.
   )
   (vl-some
     '(lambda (sub / elst)
       (if
         (and
           (= 360 (car sub))
           (setq elst (entget (cdr sub)))
           (vl-position '(0 . "ACDBASSOCVERTEXACTIONPARAM") elst)
           (vl-position '(1 . "Origin") elst)
         )
         (cdr (assoc 10 elst)) ; Point in block space.
       )
     )
     elst
   )
 )
)

Edited by Roy_043
Link to comment
Share on other sites

Just digging around Lee.

Mind you I didn't find this 'digging down'. Instead I created an array with a know center, saved as DXF and looked for the coords in that file. Using the handle of the entity I was then able to 'dig up' in the dwg. This approach, although not very sophisticated, can be quite effective.

Link to comment
Share on other sites

Just digging around Lee.

Mind you I didn't find this 'digging down'. Instead I created an array with a know center, saved as DXF and looked for the coords in that file. Using the handle of the entity I was then able to 'dig up' in the dwg. This approach, although not very sophisticated, can be quite effective.

 

Interesting approach, Roy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...