dieblockdie by Robert Bell

Discussion in 'AutoCAD' started by Ursus Uziemblo, Aug 20, 2003.

  1. Robert,
    it is very nice code, but please explain why it works :)
    in my logic (wrong) it kills only INSERT part of other block definition
    (vla-delete object) is inside (vlax-for object block..).
    How Your code find insert with given name?
    What I missed?
    Ursus Uziemblo
     
    Ursus Uziemblo, Aug 20, 2003
    #1
  2. Ursus Uziemblo

    BG Guest

    Could that file be used for AutoCAD 2000??
     
    BG, Aug 20, 2003
    #2
  3. Ursus Uziemblo

    Mark Propst Guest

    I believe that was in response to a poster who thought he had already
    deleted all direct insertions of the block but still could not purge, thus
    roberts solution would get the remaining embedded occurances.
     
    Mark Propst, Aug 20, 2003
    #3
  4. Yes.

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Could that file be used for AutoCAD 2000??
    |
    |
    | | > Robert,
    | > it is very nice code, but please explain why it works :)
    | > in my logic (wrong) it kills only INSERT part of other block definition
    | > (vla-delete object) is inside (vlax-for object block..).
    | > How Your code find insert with given name?
    | > What I missed?
    | > Ursus Uziemblo
    | >
    | >
    |
    |
     
    R. Robert Bell, Aug 20, 2003
    #4
  5. In the object model, even the layouts are simply blocks. So even a "normal"
    insertion in Model Space is a nested block, by definition.

    I loop thru all the Blocks in the Blocks collection, looping thru each
    Object in the Block itself, looking for BlockReferences (which are inserts).
    If I find a BlockReference, I check its Name, and if there is a match, I
    delete it.

    A Regen updates the drawing visibly.

    Here is the code for others that might have missed the post Ursus was
    referring to.

    ;;; Written by: R. Robert Bell
    (defun rrbI:DieBlockDie (BlkN / Doc)
    (vl-Load-Com)
    (setq BlkN (strcase BlkN)
    Doc (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
    (vlax-For Block (vla-Get-Blocks Doc)
    (vlax-For Object Block
    (if (and
    (= (vla-Get-ObjectName Object) "AcDbBlockReference")
    (= (strcase (vla-Get-Name Object)) BlkN))
    (vla-Delete Object))))
    (vla-Regen Doc acAllViewports)
    (princ))

    Usage: (rrbI:DieBlockDie "StupidBlock")


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Robert,
    | it is very nice code, but please explain why it works :)
    | in my logic (wrong) it kills only INSERT part of other block definition
    | (vla-delete object) is inside (vlax-for object block..).
    | How Your code find insert with given name?
    | What I missed?
    | Ursus Uziemblo
    |
    |
     
    R. Robert Bell, Aug 20, 2003
    #5
  6. Thanks Robert for explanation - I did not thing of modelSpace
    like a block - learn something new - thanks again
    Ursus
     
    Ursus Uziemblo, Aug 20, 2003
    #6
  7. Ursus Uziemblo

    cadtank Guest

    so a user could do the same thing with a layer, correct?
     
    cadtank, Aug 22, 2003
    #7
  8. You could use a similar approach to find what is *on* a layer (and
    optionally delete it if that is what you wish). However, layers can still be
    referenced by other conditions, such as a PViewport freezing that layer.

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | so a user could do the same thing with a layer, correct?
    |
    |
    | | > In the object model, even the layouts are simply blocks. So even a
    | "normal"
    | > insertion in Model Space is a nested block, by definition.
    | >
    | > I loop thru all the Blocks in the Blocks collection, looping thru each
    | > Object in the Block itself, looking for BlockReferences (which are
    | inserts).
    | > If I find a BlockReference, I check its Name, and if there is a match, I
    | > delete it.
    | >
    | > A Regen updates the drawing visibly.
    | >
    | > Here is the code for others that might have missed the post Ursus was
    | > referring to.
    | >
    | > ;;; Written by: R. Robert Bell
    | > (defun rrbI:DieBlockDie (BlkN / Doc)
    | > (vl-Load-Com)
    | > (setq BlkN (strcase BlkN)
    | > Doc (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
    | > (vlax-For Block (vla-Get-Blocks Doc)
    | > (vlax-For Object Block
    | > (if (and
    | > (= (vla-Get-ObjectName Object)
    | "AcDbBlockReference")
    | > (= (strcase (vla-Get-Name Object)) BlkN))
    | > (vla-Delete Object))))
    | > (vla-Regen Doc acAllViewports)
    | > (princ))
    | >
    | > Usage: (rrbI:DieBlockDie "StupidBlock")
    | >
    | >
    | > --
    | > R. Robert Bell, MCSE
    | > www.AcadX.com
    | >
    | >
    | > | > | Robert,
    | > | it is very nice code, but please explain why it works :)
    | > | in my logic (wrong) it kills only INSERT part of other block
    definition
    | > | (vla-delete object) is inside (vlax-for object block..).
    | > | How Your code find insert with given name?
    | > | What I missed?
    | > | Ursus Uziemblo
    | > |
    | > |
    | >
    | >
    |
    |
     
    R. Robert Bell, Aug 22, 2003
    #8
  9. Ursus Uziemblo

    cadtank Guest

    cool, thanks.
     
    cadtank, Aug 22, 2003
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.