GetAttributes if dwg is not current?

GetAttributes if dwg is not current?

mdhutchinson
Advisor Advisor
383 Views
5 Replies
Message 1 of 6

GetAttributes if dwg is not current?

mdhutchinson
Advisor
Advisor
If you have a valid AcadBlockReference... can you use GetAttributes successfully if the drawing is open but not the active document?
0 Likes
384 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
certainly...the significant word is "valid"
:-)
...but there must be something "behind" the question, otherwise you'd just
try it and see....
is something not working for you?


wrote in message news:5773104@discussion.autodesk.com...
If you have a valid AcadBlockReference... can you use GetAttributes
successfully if the drawing is open but not the active document?
0 Likes
Message 3 of 6

mdhutchinson
Advisor
Advisor
I had an idea that may take me a while to implement... but I really didn't want to go down the road if it wouldn't work...
0 Likes
Message 4 of 6

Anonymous
Not applicable
well, you don't have to implement a whole program to test one specific
question.
the crux of the thing is that you need a reference to an AcadBlockReference
object
Depending on where the variable is declared, and where it is
"de-referenced", will determine if the variable is still "valid"
In other words its a matter of scope of your variable
Additionally, it depends on the life of the object which the variable points
to.
if you get a reference from dwg1 (makes absolutely no difference if it's
"active doc" or not) and then close dwg1 and *then* try to access the
variable of course it will not still be "alive"
The variable may not have gone out of scope but the object to which it
points has, so you end up with a pointer to a Null object...not a good thing
generally....
:-)

But ...(my rewording of your original question)....does a doc have to be
"ActiveDoc" to reference objects in the document.... the answer is no.
You could cycle through all docs in the documents collection and access all
objects in all docs at any time.
:-)
hth
Mark



wrote in message news:5773241@discussion.autodesk.com...
I had an idea that may take me a while to implement... but I really didn't
want to go down the road if it wouldn't work...
0 Likes
Message 5 of 6

Anonymous
Not applicable
what you will need to be careful of in VBA is that you don't use the
built-in object ThisDrawing which always points to the currently active
document.


wrote in message news:5773241@discussion.autodesk.com...
I had an idea that may take me a while to implement... but I really didn't
want to go down the road if it wouldn't work...
0 Likes
Message 6 of 6

mdhutchinson
Advisor
Advisor
I just had a major breakthrough in the development of my application... and in my learning curve of VBA. (not withstanding .NET 8-(

Not only can I use GetAttributes successfully if the drawing which hosts the block isn't current... but I can also use HandleToObject so long as I have a valid reference to the AcadDocument...
I am a happy camper! 8-)

I am wondering what other methods I can use with only a reference to a valid acaddoc without it being current.

Now to find out, if I can write to the block attributes and use Update method on the AcadBlockReference object without the drawing being current.

Thanks for the help guys!
0 Likes