ActiveX: how to delete any geometry (circle, line, polyline...)

ActiveX: how to delete any geometry (circle, line, polyline...)

george1985
Collaborator Collaborator
1,174 Views
6 Replies
Message 1 of 7

ActiveX: how to delete any geometry (circle, line, polyline...)

george1985
Collaborator
Collaborator

Hello,
Can someone explain to me the concept of how to delete any autocad geometry?
I see that majority of objects have Delete method.
This deletes the geometry from the .dwg file (active document)

My confusion is: does ActiveX allow for a geometry to exist only in the memory, without it existing in the .dwg file?
Or more precisely: can I delete the geometry from the .dwg file, but somehow still keep it in the memory?Is this the limitation of ActiveX?

I would be grateful for any kind of help on this.

0 Likes
Accepted solutions (1)
1,175 Views
6 Replies
Replies (6)
Message 2 of 7

Ed__Jobe
Mentor
Mentor

It's not a limitation of ActiveX, but AutoCAD. Entities are drawn on-screen using the information stored in the drawing database. Deleting an entity removes it from the display and the database. You can't do what you describe using .NET either. You might describe what you are trying to do. Maybe then we can give you some other ideas.

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 7

george1985
Collaborator
Collaborator

Hi @Ed__Jobe ,
Thank you for the clarification. And also for the clarification that .NET also functions the same way.
I have an AcadBlockReference. When I Explode() it, I get the parts it consists of, but this also adds those parts to the active document.
How can get the entities from which the block reference consists of, without them being added to the active document? Do I need to iterate through them inside the AcadBlock (block definition) instead?
How do I get the 'AcadBlock' from 'AcadBlockReference' object? Based on its name, should search in active document's 'Block' table?

0 Likes
Message 4 of 7

Ed__Jobe
Mentor
Mentor
Accepted solution

I'm pressed for time right now to write code but here's what you need to do.

  1.  select the block reference
  2. iterate the Blocks collection using the name of the blockreference
    1. for eack blk in thisdrawing.blocks
      1. if blk.name = blockref.name then
        1. use blk.block collection to iterate ents in the block

 

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 5 of 7

george1985
Collaborator
Collaborator
Thank you.
I only didn't understand the last: "use blk.block collection to iterate ents in the block"

what is "blk.block"?

I know that 'Layout' has this property, but not 'AcadBlock'.
Sorry if I misunderstood your reply.
0 Likes
Message 6 of 7

Ed__Jobe
Mentor
Mentor

Yes, you're right. As I said I'm pressed for time and misspoke. Use the Item method to iterate.

For i = 0 to blk.count -1

   blk.Item(i)

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

george1985
Collaborator
Collaborator

Thank you for the help.

0 Likes