Attribute Extraction

Discussion in 'AutoCAD' started by ashokp, Mar 24, 2005.

  1. ashokp

    ashokp Guest

    Hi, I am a AutoCAD user, since 1992, I have done some small programs in autolisp, now I am trying to do one program in VBA since I know VB6. I am facing problem in getting started with this program.

    My aim is - I have a drawing with number of blocks with one attributes in the block, I just want to select one block at a time and want to see the tag name and tagvalue of each block one by one(as soon as i select one block i should get the tagvalue) and once I pick OK in message box again I should be able to selct next block whichever i Need to knwo the tag value, give me some VBA code for this I am using AutoCAD2005. so that later I can put the tagvalue and total the tagvalue.

    Please help me in doing this.
     
    ashokp, Mar 24, 2005
    #1
  2. ashokp

    juno Guest

    Couple of questions before I start coding

    1. Will each block have only one attribute (one tag and one value)?
    2 .Do you know the name of the block?
     
    juno, Mar 24, 2005
    #2
  3. ashokp

    Jeff Mishler Guest

    This should give you an idea:

    Option Explicit

    Sub Att_List()
    Dim objEnt As AcadEntity
    Dim vPick As Variant
    Dim objBlock As AcadBlockReference
    Dim vAtts As Variant
    Dim objAtt As AcadAttributeReference
    Dim I As Long
    Dim strAttlist As String

    On Error GoTo Err_Control
    Pick_Here:
    ThisDrawing.Utility.GetEntity objEnt, vPick
    If TypeOf objEnt Is AcadBlockReference Then
    Set objBlock = objEnt
    If objBlock.HasAttributes Then
    vAtts = objBlock.GetAttributes
    For I = 0 To UBound(vAtts)
    Set objAtt = vAtts(I)
    If strAttlist = "" Then
    strAttlist = "Tag: " & objAtt.TagString & ", Value: " &
    objAtt.TextString
    Else
    strAttlist = strAttlist & vbCr & "Tag: " &
    objAtt.TagString & ", Value: " & objAtt.TextString
    End If
    Next I
    MsgBox strAttlist, , "Attribute Listing for Block: " &
    objBlock.Name
    strAttlist = ""
    End If
    End If
    GoTo Pick_Here

    Err_Control:
    Select Case Err.Number
    Case Else
    Err.Clear
    End Select
    End Sub
     
    Jeff Mishler, Mar 24, 2005
    #3
  4. ashokp

    ashokp Guest

    Hi,

    1) Block name is Seats.
    2)Yes it has only one attribute and the tag is SEAT# Promt is Enter Seat Number and the Value is Varifying type.

    Regards

    ashokp
     
    ashokp, Mar 28, 2005
    #4
  5. ashokp

    ashokp Guest

    Hi Jeff.

    This code is working fine and I am sure this will help me a lot in further development.

    Thank you very much.

    Regards

    Ashokp
     
    ashokp, Mar 28, 2005
    #5
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.