GetAttributes .NET

Discussion in 'AutoCAD' started by HJohn, Dec 17, 2004.

  1. HJohn

    HJohn Guest

    I am trying to retrieve attributes using ObjectDBX and .NET, but I am getting an error. I am using this:

    Dim Blk as AXDBLib.AcadBlockReference
    Dim Att as Object

    Att=Blk.GetAttributes

    This returns a system array {system._ComObject}, my error is in trying to access each attribute from the array. Can someone give me a hand, I would really appreciate it.
     
    HJohn, Dec 17, 2004
    #1
  2. Since it returns an array, you need to give it one:

    Dim oAtts() As Object
    'get the blocks attributes
    oAtts = oBlkRef.GetAttributes

    Then you can either use a classic FOR loop:

    Dim oAtt As AcadAttributeReference
    Dim iCntr As Integer
    'iterate the attributes
    For iCntr = oAtts.GetLowerBound(0) To oAtts.GetUpperBound(0)
    ....do your work....
    Next

    Or you can use a FOR EACH loop:

    Dim oAtt As AcadAttributeReference
    'iterate the attributes
    For Each oAtt In oAtts
    ....do your work....
    Next


    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Dec 18, 2004
    #2
  3. HJohn

    HJohn Guest

    Thanks Mike. I was doing that, but I was stopping just after assigning the first element of the array to the att variable. In the local window it doesn't show the content of the att obj. as in vba, it just shows {system._comobject} and nothing else, so I though it was an error. With your confirmation I continued and printed the textstrings to the console and it worked fine, so thanks again. Is it just my computer or is it that .NET doesn't display the contents of the attributes on the local window?
     
    HJohn, Dec 20, 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.