question about accessing the "Undo memory"

Discussion in 'AutoCAD' started by MP, Apr 7, 2005.

  1. MP

    MP Guest

    why yes it will.
    of course, now that i'm trying different things I'm not getting the same
    failure anymore.

    so there's some specific sequence of events that creates the previous
    pattern.
    I'll have to wait till it happens again to check some more.
    Thanks to everyone for their ideas.
    Mark
     
    MP, Apr 8, 2005
    #21
  2. MP

    MP Guest

    well that wasn't a very long wait
    okay,
    I had a block "COL-BASE-PLAN" embedded in another block "PORCH-SOUTH-PLAN"
    I deleted the parent block
    then ran deleteblock on the subblock
    (I've revised deleteblock to also check for embedded references)

    here's the result just after erasing and manually purging the parent block.

    No inserts of COL-BASE-PLAN exist in dwg
    COL-BASE-PLAN not embedded in any blocks
    Failed to delete COL-BASE-PLAN
    Automation Error. Object is referenced

    then i did a save ("original.dwg") and reran deleteblock
    results:
    still referenced

    then i did a saveas ("test.dwg") and reran deleteblock
    results:
    still referenced

    then i reopened the original dwg name(before the saveas "test.dwg")
    Successfully deleted COL-BASE-PLAN
    voila

    then i went back to "test.dwg"
    tried deleteblock again
    results:
    still referenced

    then i uncommented the (command"dxfout") line and reran
    it did create a dxf file
    but still won't let go of the unreferenced, unembedded block

    now if i close it and reopen it, it will let go of it....here goes....
    yep, sure nuf
    Successfully deleted COL-BASE-PLAN

    so it's referenced by something....just not another block

    revised version of deleteblock
    (defun c:deleteblock()
    (adcfLoadList
    (list
    'adcfGet-Item
    'adcfGet-Layer
    'adcfGet-Object
    'adcfGet-BlockDef
    'adcfGet-ActiveDoc
    ))

    (setq blkname "COL-BASE-PLAN"
    )

    (checkForDirectInsertions blkName)
    (princ)
    )

    (defun checkForDirectInsertions (blkName / blkObj blkSet res idx)
    (setq blkobj(adcfGet-BlockDef(adcfGet-ActiveDoc) blkname))

    (setq blkset(ssget"x"(list(cons 2 blkname))))
    (if(not blkset)
    (progn
    (princ(strcat "\nNo inserts of " blkname " exist in dwg"))
    ;uncomment next line to dxfout
    ;(command"dxfout")
    (checkForNestedBlocks blkname)

    (if
    (null
    (vl-catch-all-error-p
    (setq res
    (vl-catch-all-apply
    'vla-delete
    (list blkobj)
    )
    )
    )
    );null
    (princ(strcat"\nSuccessfully deleted " blkname))
    (princ(strcat"\nFailed to delete " blkname "\n"
    (vl-catch-all-error-message res)))
    );if
    );progn
    (progn
    (princ(strcat"\nFound " (itoa (sslength blkset)) " inserts of " blkname))
    (setq idx 0)
    (repeat(sslength blkset)
    (princ(strcat"\nOn Layer: "(adcfGet-Layer(adcfGet-Object(ssname blkset
    idx)))))
    (setq idx (1+ idx)))

    )
    );if
    )

    (defun CheckForNestedBlocks(blkName / parentBlock blkCol foundit)
    (adcfLoadList
    (list
    'adcfType-IsBlock
    'adcfGet-Blocks
    'adcfGet-Name
    'adcfGet-ActiveDoc
    ))

    (setq blkName(strcase blkName))

    (setq blkCol(adcfGet-Blocks(adcfGet-ActiveDoc)))

    (vlax-for oBlk blkCol
    (vlax-for oItem oBlk
    (if(adcfType-IsBlock oItem)
    (if(=(strcase(adcfGet-Name oItem))blkName)
    (progn
    (setq foundit 1)
    (setq parentBlock(adcfGet-Name oblk))
    (princ(strcat "\nFound " blkName " embedded in " parentBlock ))
    ;delete parent if it's unreferenced...
    (checkForDirectInsertions parentBlock)
    )
    )
    )
    );for item in block
    );for block
    (if(not foundit)
    (princ(strcat "\n" blkName " not embedded in any blocks")))
    )
     
    MP, Apr 8, 2005
    #22
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.