Creating an array like AutoCad does it

Creating an array like AutoCad does it

NickBrege
Enthusiast Enthusiast
1,411 Views
6 Replies
Message 1 of 7

Creating an array like AutoCad does it

NickBrege
Enthusiast
Enthusiast

When using the .ArrayRectangular method to create an array of circles it creates them as separate circles.  So for example if I create a 10 x 20 array I will have 200 separate circle entities.  When I create the same array manually in AutoCad, all 200 circles are "grouped" into 1 entity that has handles that can be clicked and dragged to dynamically change the row/column spacing and quantity.  Is it possible to create an array this same way using the Activex API?

0 Likes
1,412 Views
6 Replies
Replies (6)
Message 2 of 7

norman.yuan
Mentor
Mentor

With AutoCAD built-in command Array/ArrayXXX, (take ArrayRect for instance) the result entity array can be "Associated", or "Not Associated". The former appear as a single entity grouping all entities together, with special grips, which allow user to change the array (row/column/distance...). Actually, the array is a dynamic block reference. The latter is simply multiple individual entities places in row/column/distance. Also, the former can be exploded into individual entities.

 

I am not sure why you ask if there is ActiveX (COM API) to do it in this .NET API forum, but anyway, with COM API, the answer is yes or no. Yes, AcadEntity has method ArrayPolar()/ArrayRectangular(). But no, they do not result in associated array. The array generated is an array of non-associated individual entities.

 

With either .NET API or COM API, one can easily programmatically generate an array of non-associated entities with minimum math. But to get an array of associated entities as AutoCAD built-in command does, there is no API exposed, I think. As alternative option, we can group the array of individual entities together, which can also be done easily with .NET API/COM API. 

 

To mimic AutoCAD built-in associated array (with special grips) programmatically, it might be doable with either Overrule, or Associate Framework, or the combination of both. In this case, the attempt would only be possible with .NET API (or ObjectARX C++), but not COM API. As aborementioned, the associated array is a dynamic block reference, and there is no API available to programmatically compose a dynamic block, we can only try to mimic the AutoCAD built-in one as close as we can, until one day Autodesk makes dynamic block composing API available, if it ever happens.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 7

NickBrege
Enthusiast
Enthusiast

"I am not sure why you ask if there is ActiveX (COM API) to do it in this .NET API forum..."

 

 

Sorry about that.  Is there a more appropriate forum for ActiveX questions?  Thanks...

 

0 Likes
Message 4 of 7

norman.yuan
Mentor
Mentor

For AutoCAD ActiveX/COM API, the discussion forum is here:

 

https://forums.autodesk.com/t5/visual-basic-customization/bd-p/33

 

Regardless, I have answered your question:

 

You cannot use COM API's AcadEntity.ArrayXXX() method to achieve the same effect as AutoCAD built-in command (associated array). The closest thing you can do with COM API is to place all the entities into a Group.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 7

NickBrege
Enthusiast
Enthusiast

So can you make an associated array using the .Net API?

0 Likes
Message 6 of 7

NickBrege
Enthusiast
Enthusiast

Never mind ... I see you already answered that question.

0 Likes
Message 7 of 7

ActivistInvestor
Mentor
Mentor

@nbregeJ99TL wrote:

When using the .ArrayRectangular method to create an array of circles it creates them as separate circles.  So for example if I create a 10 x 20 array I will have 200 separate circle entities.  When I create the same array manually in AutoCad, all 200 circles are "grouped" into 1 entity that has handles that can be clicked and dragged to dynamically change the row/column spacing and quantity.  Is it possible to create an array this same way using the Activex API?


The only way to do that is

 

   1) native ObjectARX/C++ or,

   2) scripting the ARRAY command from code (LISP, VBA/ActiveX, or .NET)

 

Associative arrays are not dynamic blocks, they're just anonymous blocks with persistent reactors attached (the reactors are associative framework objects). They also make heavy use of overrules to provide grip editing and other functionality.

 

 

 

0 Likes