Jump to content
eimimitu

Center Point of Polar Array

Recommended Posts

eimimitu

Working on a utility to rotate polar type array half the angle between items to create a stagger effect of multiple concentric arrays.

 

As far as my research turned up, there is no lisp property for the center point of the array.

 

An array seems to be an anonymous block who's insertion point is always WCS (0 0 0), so if I apply a rotation property it does it from that point and not center point of array.

 

Solution 1: Select the array, highlight grips with (sssetfirst), (getpoint) the center grip the rotate from that point... [not crazy about this option]

 

Solution 2: Select the array, run the list command and extract the center point property from the log file [works marginally as the precision is only 8 decimal places so it ends up displacing it slightly]

 

Any ideas?

Share this post


Link to post
Share on other sites
rlx

probably there's a more efficient or better way but maybe this helps :

 

; p1 & p2 can be 2 or 3 point : (GetCenterPoint '(0 0 0) '(2 2 2)) (GetCenterPoint '(0 0) '(4 4))
(defun GetCenterPoint (p1 p2) (mapcar (function (lambda (a b) (/ (+ a b) 2.0))) p1 p2))

; get (bounding)box center, either with object or with list of 2 points.
; test (GetBoxCenter (car (entsel))) , (GetBoxCenter '((0 0 0) (2 2 2)))
(defun GetBoxCenter ( %obj / _typ pl )
 (if (eq (setq _typ (type %obj)) 'ENAME) (setq %obj (vlax-ename->vla-object %obj)))
 (if (vl-consp %obj) (GetCenterPoint (car %obj) (cadr %obj)) (if (setq pl (GetObjectBB %obj)) (GetCenterPoint (car pl) (cadr pl)))))

gr.Rlx

Share this post


Link to post
Share on other sites
eimimitu

Pretty clever, however the bounding box method works only if:

 

1. polar array has 360 degree fill angle

2. the "rotate copied items" option is "yes"

3. non-full circle arrays are symmetrical in the x or y axis [via midpoint of the bounding box's top edge]

 

The routine also has an option for arrays with less than 360 fill and an option for rotate direction [ccw or cw], which complicates things a bit too.

 

Anything like "snap and select grip closest to coordinate (x,y)" that can be used?

Share this post


Link to post
Share on other sites
rlx
Pretty clever, however the bounding box method works only if:

 

1. polar array has 360 degree fill angle

2. the "rotate copied items" option is "yes"

3. non-full circle arrays are symmetrical in the x or y axis [via midpoint of the bounding box's top edge]

 

The routine also has an option for arrays with less than 360 fill and an option for rotate direction [ccw or cw], which complicates things a bit too.

 

Anything like "snap and select grip closest to coordinate (x,y)" that can be used?

 

I was just using this code for another program when I saw your post , so I thought , mm, would it work for that too , so I made a polar array (full circle) and I tried it and it seemed to work. I even didn't get to the part where I expected autocad would ask for the angle to fill , rotate objects etc , beng , there was the array , so I didn't gave it much thought to be honest, if it would work on a partial array so I haven't tried that (yet). I did try to look at the vla properties to see if there was a center property or something because osnap (center or insertionpoint) didn't work. There is one group of coordinates but haven't inspected it closer , thinkin'/ hoping the boundingbox option would be enough...

Share this post


Link to post
Share on other sites
eimimitu

I do appreciate your efforts rlx...

 

I ran entget and vlax-dump-object on it and didn't find any usable coordinates... Only one I found is the origin of the block which is 0,0,0 :unsure:

Share this post


Link to post
Share on other sites
rlx
I do appreciate your efforts rlx...

 

I ran entget and vlax-dump-object on it and didn't find any usable coordinates... Only one I found is the origin of the block which is 0,0,0 :unsure:

 

 

If you select an array with the properties dialog from autocad you do find the basepoint but in the vla prop's there's not.

 

 

Command: SO

; IAcadLWPolyline: AutoCAD Lightweight Polyline Interface

; Property values:

; Application (RO) = #

; Area (RO) = 383.594

; Closed = -1

; ConstantWidth = 0.0

; Coordinate = ...Indexed contents not shown...

; Coordinates = (-8.125 0.0 -1.875 23.75 8.125 -1.25 ... )

; Document (RO) = #

; Elevation = 0.0

; EntityTransparency = "ByLayer"

; Handle (RO) = "239E"

; HasExtensionDictionary (RO) = 0

; Hyperlinks (RO) = #

; Layer = "0"

; Length (RO) = 100.606

; Linetype = "ByLayer"

; LinetypeGeneration = 0

; LinetypeScale = 1.0

; Lineweight = -1

; Material = "ByLayer"

; Normal = (0.0 0.0 1.0)

; ObjectID (RO) = 42

; ObjectName (RO) = "AcDbPolyline"

; OwnerID (RO) = 43

; PlotStyleName = "ByLayer"

; Thickness = 0.0

; TrueColor = #

; Visible = -1

 

 

Guess information is barried a little deeper :(

polar.png

Share this post


Link to post
Share on other sites
rlx

However, if I convert the polar array object back to ename and dig a little deeper I find entry {block} *U1 and if I go down I get {parts} and the first entry of *U0 shows the correct basepoint , in my case 136,185. So it should be possible but I'm note sure at this moment how to get there programmatically.

polar-2.jpg

Share this post


Link to post
Share on other sites
eimimitu

cool.. it looks like you're onto something... however, how did you get there?

 

First window looks the same for me "VLA-OBJECT"... but when I double click "Application" it gives me a different window

Share this post


Link to post
Share on other sites
rlx
cool.. it looks like you're onto something... however, how did you get there?

 

First window looks the same for me "VLA-OBJECT"... but when I double click "Application" it gives me a different window

 

usually the data is hiding in the sub entities , group codes 330 / 360 etc but I searched most of them through lisp with no succes so far ... something like those famous russian dolls within a doll. It looks like I have to seach for a vertex parameter. Tried dxf the drawing and found the parameter (AcDbAssocVertexActionParam) but it seems only C# is able to get to it. Dont have the data on my notebook here at home but on the pc at my work. Maybe there's another way but I haven't found it ... yet... but if I will , I'll let you know ofcourse.

 

gr. Rlx

Share this post


Link to post
Share on other sites
Grrr
.. something like those famous russian dolls within a doll.

 

Matrioshkas, although you could find "larger ones" in the code. :lol:

 

BTW I was able to dig into the main block definition, from there to dig-out the block references (the diamonds in your picture), and extract their base points.

Also I found the base point of the main block reference -

But the disappointing part was when I entmaked point entities on these insertion points to preview if graphically they are correct (answer: no - they require translation).

 

And BTW to keep "digging" in the last dialog you popped, you have to right click->inspect raw data to see the dxf list.

Share this post


Link to post
Share on other sites
rlx
Matrioshkas, although you could find "larger ones" in the code. :lol:

 

ok Matrioshkas it is then :-)

 

But I am a little surprised / disappointed that this info (no not the dolls) , I mean the centerpoint of the polar array , is not just one of the general properties. It is a grip point and so it has some kind of object parameter / reactor. Awel , I'll digg some more 2morrow...

 

gr. Rlx

Share this post


Link to post
Share on other sites
Grrr
ok Matrioshkas it is then :-)

 

But I am a little surprised / disappointed that this info (no not the dolls) , I mean the centerpoint of the polar array , is not just one of the general properties. It is a grip point and so it has some kind of object parameter / reactor. Awel , I'll digg some more 2morrow...

 

gr. Rlx

 

Me too, I was expecting atleast to find the "Base X" or "Base Y" properties.

I even though these grips might be threated as 'dynamicblockparameter(s)'.

In the end like I said, just found the main block for the polararray, which contained inside the references of these 'diamonds'.

And the count of these references changed if the 'items' in the array are changed.

Also the base points of the sub-blocks seemed to be their boundingbox centroids.

Share this post


Link to post
Share on other sites
rlx

I don't have a degree in math but if you have 2 points that lie on an arc , shouldn't you be able to work out the center?

Share this post


Link to post
Share on other sites
Grrr

I think atleast the arc-radius and some angle would be required (just waiting for the mathematician:roll: ).

Share this post


Link to post
Share on other sites
Lee Mac

Here's one way -

(defun LM:PolarArrayCenter ( ent / bpt enx rad sta )
   (if
       (and
           (setq enx (entget ent))
           (= "INSERT" (cdr (assoc 0 enx)))
           (setq enx (member '(102 . "{ACAD_REACTORS") enx))
           (setq enx (assoc 330 enx))
           (setq enx (entget (cdr enx)))
           (= "ACDBASSOCDEPENDENCY" (cdr (assoc 0 enx)))
           (setq enx (assoc 330 enx))
           (setq enx (entget (cdr enx)))
           (= "ACDBASSOCACTION" (cdr (assoc 0 enx)))
           (setq rad (cdr (assoc 40 (member '(1 . "Radius") enx))))
           (setq sta (cdr (assoc 40 (member '(1 . "StartAngle") enx))))
           (setq enx (assoc 360 enx))
           (setq enx (entget (cdr enx)))
           (= "ACDBASSOCARRAYACTIONBODY" (cdr (assoc 0 enx)))
           (setq bpt (cdr (assoc 11 enx)))
       )
       (polar bpt sta (- rad))
   )
)

Share this post


Link to post
Share on other sites
Grrr
Hint:

Dig deeper in the entity list of the ACDBASSOCACTION entity.

 

Yeah, it kinda reminded me of that thread.. guess I'm a bad digger (but really wasn't too motivated to solve this).

 

 

Here's one way -

 

Lee the mathemagician, your skills are scary. :beer:

Share this post


Link to post
Share on other sites
eimimitu

Damn... I have a long way to go... Mind blown!!!

 

It worked very well... Thank you very much!

 

One quick thing though... Any idea why it shows both the assoc 1 "Startangle" and "Fillangle" at 3.14159 on a 180 degree fill array?

Share this post


Link to post
Share on other sites
BIGAL

180=3.14159 as radians. 2xpi = 360.

Share this post


Link to post
Share on other sites
eimimitu

oh duh... I was thinking 3.14159 was 0 deg...:P... cool thanks BIGAL.. and another thanks to all the contributors

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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