Author Topic: write block names to file  (Read 5433 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
write block names to file
« on: December 03, 2013, 01:54:09 PM »
I cant seem to get my block names to write out to a file.  I have my File Scripting Object working, but I am having trouble iterating through my block collection.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: write block names to file
« Reply #1 on: December 03, 2013, 01:56:58 PM »
This is basically what I am doing
Code: [Select]
objSelset.Select acSelectionSetAll

Dim objblkname As AcadBlockReference
For Each objblkname In objSelset
MyFile.Writeline objblkname.Name
Next

I crashed autocad and I hadn't saved, so I put that together from memory
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: write block names to file
« Reply #2 on: December 03, 2013, 01:58:13 PM »
Part of the problem is some of the things in the selectionset aren't blocks, so there is no NAME property, so that is where it crashes.  I can't seem to get it to only return inserted blocks
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: write block names to file
« Reply #3 on: December 03, 2013, 08:53:25 PM »
Hi David,
Seems like you need a property.available test.

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.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: write block names to file
« Reply #4 on: December 04, 2013, 01:13:09 AM »
either that or set up your selection set with a filter ;)

<edit> found a quick link with some info: http://adndevblog.typepad.com/autocad/2012/07/vba-how-to-setup-selectionset-filters-for-a-block-or-layer.html
« Last Edit: December 04, 2013, 01:17:06 AM by MickD »
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: write block names to file
« Reply #5 on: December 04, 2013, 01:32:57 AM »
Yep,

Will any of these blocks be dynamic?

If so, you may need to deal with EffectiveName for BlockReferences.


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.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: write block names to file
« Reply #6 on: December 04, 2013, 11:29:03 AM »
Thanks guys, that was what I needed.  All is good
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)