Block Reference & GetAttributes & .NET

Discussion in 'AutoCAD' started by hzdwbm, Oct 8, 2004.

  1. hzdwbm

    hzdwbm Guest

    As you already know .NET does not have a Variant data type. I have been trying to get the attributes from a block reference using this code with no luck:

    =============================================
    objAttributes is an Object data type variable

    For itemCounter = 0 To objModelSpace.Count - 1
    Select Case objModelSpace.Item(itemCounter).ObjectName
    Case "AcDbBlockReference"
    objBlockReference = objModelSpace.Item(itemCounter)
    objAttributes = objBlockReference.GetAttributes()
    End Select
    Next
    =============================================

    The error that I am getting is An unhandled exception of type 'System.ExecutionEngineException' in the line

    =============================================
    objAttributes = objBlockReference.GetAttributes()
    =============================================

    The weird part is that I am able to see the attributes of the block reference using the IDE Watch window

    Has anyone have had this problem using VB.NET 2002?
    Is there another way of retrieving the block reference attributes?

    Thanks for all your help
    Luis
     
    hzdwbm, Oct 8, 2004
    #1
  2. What type of variable is objAttributes?
     
    Frank Oquendo, Oct 8, 2004
    #2
  3. Yeah, it needs to be:

    Dim oAtts() As Object
    oAtts = oBlkRef.GetAttributes

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 9, 2004
    #3
  4. hzdwbm

    hzdwbm Guest

    This is the code that I am using and it is still giving me an error

    An unhandled exception of type 'System.ExecutionEngineException' occurred in system.windows.forms.dll

    Code
    ================================================
    Dim objApp As AutoCAD.AcadApplication
    Dim objDocs As AutoCAD.AcadDocuments
    Dim objDoc As AutoCAD.AcadDocument
    Dim objModelSpace As AutoCAD.AcadModelSpace
    Dim objBlockReference As AutoCAD.AcadBlockReference
    Dim objAttributes() As Object

    Dim itemCounter As Integer

    Try
    objApp = GetObject(, "AutoCAD.Application.16")
    Catch
    Try
    objApp = CreateObject("AutoCAD.Application.16")
    Catch
    End Try
    End Try

    objDocs = objApp.Documents
    objDoc = objDocs.Open("C:\SomeDrawing.dwg")

    objModelSpace = objDoc.ModelSpace

    For itemCounter = 0 To objModelSpace.Count - 1
    Select Case objModelSpace.Item(itemCounter).ObjectName
    Case "AcDbBlockReference"
    objBlockReference = objModelSpace.Item(itemCounter)
    objAttributes = objBlockReference.GetAttributes()
    End Select
    Next

    objDoc.Close()
    ===============================================
     
    hzdwbm, Oct 13, 2004
    #4
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.