Author Topic: vla-Delete on Block collection (error)  (Read 11974 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: vla-Delete on Block collection (error)
« Reply #15 on: November 07, 2005, 05:37:54 PM »
Some more testing.......
This problem also occurs when using similar code in VBA
Even in ODBX documents the block defs will not delete

Luis's routine is VERY thorough! It deletes the Layout blocks as well as any standard blocks! Yet, unlike the ActiveX delete method, deleting the Layout's block does NOT remove the layout.....

Superpurge by Manusoft properly removes all the blocks that should be removed.


T.Willey

  • Needs a day job
  • Posts: 5251
Re: vla-Delete on Block collection (error)
« Reply #16 on: November 07, 2005, 06:30:22 PM »
Here is the updated version, I think is working now....


Seems to have worked here on my simple little test drawing.  I will test more when I get a chance to, and let you know the results.
Thanks Luis.  Is there anyway to translate the arx code to vlisp? activex? lisp?  :roll:  Just asking.

Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: vla-Delete on Block collection (error)
« Reply #17 on: November 07, 2005, 06:44:44 PM »
I might been able to translate it into C# but do not want to get in trouble with the dark side people...
Have fun.
Luis.

Not really :angel:.  It was a wish.  :wink:
Thanks Luis.
Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: vla-Delete on Block collection (error)
« Reply #18 on: November 07, 2005, 06:47:43 PM »
Here is the updated version, I think is working now....
Yep, works here as well, although I had to run it twice to remove 2 of the blocks.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vla-Delete on Block collection (error)
« Reply #19 on: November 07, 2005, 07:11:40 PM »
Tim,
Can you tell me what you believe the code you posted is trying to do. ?

Regards,
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: vla-Delete on Block collection (error)
« Reply #20 on: November 07, 2005, 07:21:52 PM »
Luis,
I think that leaving it up to the user to run as many times as needed is better. HERE is my test drawing. It has 2 drawings inserted as blocks that need to be erased. Once erased, the nested blocks "8-X-11" & "point" are the 2 that a.) Tim's code leaves behind & b.) your code needs to run twice to remove (but I'm sure that it's due to the main blocks need to be removed first)

Kerry,
Tim's code removes unused items from the specified collections.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: vla-Delete on Block collection (error)
« Reply #21 on: November 07, 2005, 07:22:23 PM »
Tim,
Can you tell me what you believe the code you posted is trying to do. ?

Someone on the AUGI forums was complaining about seeing the purge command echo, so I was just trying to see if I could come up with a routine that would do the same thing as the purge command.  It is supposed to delete all objects that it can, for the collections provided within the code.  I think it is the layer, block, text styles and line type.

Did I miss something?

Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Bob Wahr

  • Guest
Re: vla-Delete on Block collection (error)
« Reply #22 on: November 07, 2005, 08:28:40 PM »
Did I miss something?

Tim
Min. dimstyles

named layer filters would also be nifty.  Other than those, you seem to have the biggies covered.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vla-Delete on Block collection (error)
« Reply #23 on: November 07, 2005, 08:34:54 PM »
Tim

Something like this may be more efficient, and a little easier to read ..

.. but doesn't solve your/the referencing issue.
Code: [Select]
...
...
(repeat 2
  (foreach i '("Blocks" "Blocks" "DimStyles" "Linetypes" "Layers" "TextStyles")
    (vlax-for Obj (vlax-get Doc i)
      (if (not (vlax-property-available-p Obj 'IsLayout))
        (vl-catch-all-apply 'vla-delete (list Obj))
      )
    )
  )
)
...
...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vla-Delete on Block collection (error)
« Reply #24 on: November 07, 2005, 08:39:25 PM »
I seem to recall that Tont T. had a reference counter similar to the code Michael posted, but my brain is full of other things at the moment and I can't recall if it was used to solve this issue.
 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: vla-Delete on Block collection (error)
« Reply #25 on: November 07, 2005, 11:56:50 PM »
Something like this may be more efficient, and a little easier to read ..
Dog gone it.....that's what I was trying to do and I just failed to wrap my mind around it, so I suggested the code that Tim used. I knew it was simple, but I was helping Tim while I was also in the midst of my own fires......

Sorry for making your code pukey, Tim. Kerry is absolutely right.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vla-Delete on Block collection (error)
« Reply #26 on: November 08, 2005, 12:05:35 AM »
The fact that you had the logic, and it worked, made it easy for a new set of eyes Jeff.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: vla-Delete on Block collection (error)
« Reply #27 on: November 08, 2005, 07:44:55 AM »
Back to the incorrect referencing business, <guessing> it may be because when entities are deleted they aren't truly deleted per se, that is, they are flagged for deletion but still reside in the drawing database. When the drawing is saved entities flagged for deletion don't get to go along for the ride, thus are deleted. The fact that they still reside in the database seems to trip up the ability to tell whether there are fully disassociated from other entities.

Regarding the authorship of my initial code snip I based it on about a minute of observation in my hotlinked props utility - I can dynamically hop from entity to entity, object to object, as long as the target object / entity name is valid (not deleted) by merely double clicking the object / ename. Observe --



While I've little doubt Tony probably penned something similar years ago (generally speaking he's light years ahead of the great unwashed) he was not the source of what I had posted.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: vla-Delete on Block collection (error)
« Reply #28 on: November 08, 2005, 08:19:22 AM »
Hi Michael,

Flagged for deletion seems to ring a bell. I recall a similar issue with layers that had been deleted but subsequent calls thought they still existed. ... I really have to get a good reference system organised to find this stuff again .. I think Glenn R. did some research on the issue.

Re the origin of your post code , I hadn't thought for a second that anyone other than you was the source.

Regards
kwb
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: vla-Delete on Block collection (error)
« Reply #29 on: November 08, 2005, 08:43:15 AM »
Minor tangent ...

Michael what did you use to create that gif? ( blockcounts.gif )
TheSwamp.org  (serving the CAD community since 2003)