Automation Error on AcadBlockRef in PaperSpace/ModelSpace

Discussion in 'AutoCAD' started by rjlohan, Jul 29, 2004.

  1. rjlohan

    rjlohan Guest

    I have a function in an ActiveX dll (written in VB6) which finds a specific block in the ModelSpace (or PaperSpace), calls GetAttributes on that Block, and is then supposed to modify certain Attributes depending on their .TagString property.

    However, whenever I try to access (read or write) the .TagString or .TextString of an element in the attribute array, I get a 'Object doesn't support this action' error, or the VB6 IDE just crashes (during development/debug).

    If I use VB6 IDE's LocalWatch window I can see the values of the .TextString/.TagString properties in the attribute I'm referencing, but if I let the code run, it crashes out. This exact same function (with appropriate context modifications) works as expected in AutoCAD's VBA environment, but consistently causes this error when Automating from VB...

    Virtually identical code to access the stored block works fine. But as soon as I try to get the block on the PaperSpace or ModelSpace... crash!

    I've attached a file showing the code (trimmed slightly of irrelevant bits). Both lines marked with an * cause the problem. Interestingly, if I access other properties (e.g - .Alignment, there's no problem...)

    ??
     
    rjlohan, Jul 29, 2004
    #1
  2. rjlohan

    MickyV Guest

    The GetAttributes method returns a Variant array, so try declaring your ThisAttrs variable as a variant instead of an AttributeRef. Might also want to check the HasAttributes property to verify that the block does have attributes.
     
    MickyV, Jul 29, 2004
    #2
  3. rjlohan

    rjlohan Guest

    Brilliant! That seems to have done the trick! Cheers mate. :)

    That'll learn me not to gloss over the help files. I ignored the bit that said GetAttributes returns a Variant, and just saw the bit that said the Variant is an array of AttributeReferences... :p
     
    rjlohan, Jul 29, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.