How to get Center Point of Circle made from Array.

How to get Center Point of Circle made from Array.

duongphong29
Enthusiast Enthusiast
2,044 Views
1 Reply
Message 1 of 2

How to get Center Point of Circle made from Array.

duongphong29
Enthusiast
Enthusiast

I am trying to get Coordinates of the Center Point of Circle objects. It works fine if it is a normal Circle but things get more complicated when I work on an array that consists of the number of circles in them.

Since Array was defined as AcadBlockReference, I can not access to any individual circle in them? I have tried to explode all things but this still has trouble: It creates a bunch of circles that overlap on the array. Those circles are still defined as AcadBlockReference. 

 

Is there any method for me to work on those? Thank you very much

0 Likes
Accepted solutions (1)
2,045 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor
Accepted solution

VBA code (i.e. via AutoCAD COM API) does not know if an anonymous block reference is an entity array or not. So, in the workflow of your VBA code execution, you should somehow make sure the target anonymous block reference is indeed an entity array bore you use code to explode it.

 

Now assume you are sure the block reference to be exploded is entity array, the you simply explode the entity array, and then explode each "element" entity of the obtained entities of the first explosion. That is because when AutoCAD creates entity array, it first make the element entity into an anonymous block, and then generate all elements according to array parameters (rows, columns, space distance...) as block reference of that "element" anonymous block definition; then AutoCAD place all the elements (block references) into anther anonymous block as entity array. So, after 2 round explosions (first round explodes the entity array itself, once; the second round explodes each of the element block references generated from the first round).

 

You need to remember, Explode() method execution is different from command Explode: it returns an array of entities from the block reference being exploded, BUT, the original block reference itself is not affected. It is up to your code to decide when to do with the entities generated by the explosion: erase them, move them, or leave them at the place (that is what you described: "... creates a bunch of circle overlap...).

 

In your code, you can access the circles' data (center point) and then erase them.

 

The other way to obtain the circle data is to go to the entity array's anonymous block definition, and loop through the entity (element block reference) in it, and for each element, go to its anonymous block definition again, loop though its element, which is circle, of course. Based on block reference's geometric transformation, you can calculate where each circle's center point is according to the entity array's position.

 

Norman Yuan

Drive CAD With Code

EESignature