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

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
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

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
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

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
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

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.

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

--> Donate to theSwamp<--

MickD

  • King Gator
  • Posts: 3520
  • (x-in)->[process]->(y-out)
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 »
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"The E in Javascript stands for 'easy'." Florin Pop tweet

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.


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

--> Donate to theSwamp<--

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
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