TheSwamp

Code Red => VB(A) => Topic started by: David Hall on December 03, 2013, 01:54:09 PM

Title: write block names to file
Post by: David Hall 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.
Title: Re: write block names to file
Post by: David Hall 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
Title: Re: write block names to file
Post by: David Hall 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
Title: Re: write block names to file
Post by: Kerry on December 03, 2013, 08:53:25 PM
Hi David,
Seems like you need a property.available test.

Title: Re: write block names to file
Post by: MickD 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
Title: Re: write block names to file
Post by: Kerry 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.


Title: Re: write block names to file
Post by: David Hall on December 04, 2013, 11:29:03 AM
Thanks guys, that was what I needed.  All is good