Get Block geometry

Get Block geometry

george1985
Collaborator Collaborator
407 Views
2 Replies
Message 1 of 3

Get Block geometry

george1985
Collaborator
Collaborator

Dear Autocad colleagues,

How to get geometry of a Dynamic block instance, via ActiveX API?
I looked at the BlockReference documentation page, and there is only Explode() method.
Sadly this method actually explodes the dynamic block, before returning its geometry items.

So, is it not possible to get Block instance geometry via ActiveX API?
Not even if we call some Lisp command?
It can be achieved only via NET Autocad API?

I would be very grateful for any kind of help, as the moment I don't know how to proceed with my project.
Thank you for the help in advance.

0 Likes
Accepted solutions (1)
408 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor
Accepted solution

You need to understand how dynamic blocks and regular blocks work. Let's start with regular blocks. They have a definition object called a Block. This stores all the geometry of the block. Then, the insertion or instance of a block is called a BlockReference. This object only stores the block name and insertion point and rotation. Then the entities of the block definition are drawn at this location. Now, when you have a dynamic block, if you change any of the block properties, an unnamed block is created to represent the transformed block. It has a name that begins with "*U####". The BlockReference will then contain an EffectiveName property that is the value of the original block name, not the unnamed block, which will be the Name property. To get the entities of the unnamed block, use the Name property to query the Blocks collection. To get the entities of the original block, use the EffectiveName property. When you find the block definition, you use the Block.Item method to iterate each item. There are examples of how to do that in this forum. For example, this thread.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 3

george1985
Collaborator
Collaborator

Hi @Ed__Jobe ,
Thank you very much for the brilliant answer and explanation of how blocks work!
I owe you a beer for this shared knowledge.

0 Likes