GetAttribute...

Discussion in 'AutoCAD' started by kyheulon, Aug 19, 2004.

  1. kyheulon

    kyheulon Guest

    Hello Everyone...

    I'm just getting into VB for AutoCAD and I know this question shows up a lot, but I can get it figured out from those answered. Anyway...

    I'm trying to read the value of an attribute in a block in a layout. I've started with the following code, but can't figure out how to "read" the attributes in the block.

    Thanks for any help, and please explain it like I'm an idiot, because... well... I am.

    Dim EntBlock As AcadBlock
    Dim EntBlkRef As AcadBlockReference
    Dim BlkAttrib As Variant
    Set EntBlock = ThisDrawing.Blocks.Item("blockname")
    'missing somthing here....
    BlkAttrib = EntBlkRef.GetAttributes()
     
    kyheulon, Aug 19, 2004
    #1
  2. kyheulon

    Tom Roberts Guest

    GetAttribute method applies to the AcadBlockRef object not the AcadBlock
    object
    Something like this...

    ------------------
    Dim objBlkRef As AcadBlockReference
    Dim varAttribs As Variant
    Dim varPnt As Variant

    ThisDrawing.Utility.GetEntity objBlkRef, varPnt, "Pick a block"

    If objBlkRef.HasAttributes Then
    varAttribs = objBlkRef.GetAttributes
    End If
    -------------------------

    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia


    lot, but I can get it figured out from those answered. Anyway...
    started with the following code, but can't figure out how to "read" the
    attributes in the block.
     
    Tom Roberts, Aug 19, 2004
    #2
  3. kyheulon

    kyheulon Guest

    I don't want to the user to have to pick the block. I want this to run without user direction or input. How do I assign "BlkAttrib" a AcadBlockRef in an automated way?
     
    kyheulon, Aug 19, 2004
    #3
  4. Something like this?

    Dim oSSet As AcadSelectionSet, iGroup(0 To 1) As Integer, vData(0 To 1) As
    Variant
    Dim oBlkRef As AcadBlockReference
    Dim vAttribs As Variant, vAttrib As Variant

    Set oSSet = ThisDrawing.SelectionSets.Add("<Selection Set Name>")
    iGroup(0) = 0: vData(0) = "INSERT"
    iGroup(0) = 2: vData(0) = <block name>
    oSSet.Select acSelectionSetAll, , , iGroup, vData

    For Each oBlkRef In oSSet
    If oBlkRef.HasAttributes Then
    vAttribs = oBlkRef.GetAttributes
    For Each vAttrib In vAttribs
    If vAttrib.TagString = <the one you want>
    ' do something with vAttrib.TextString
    End If
    Next vAttrib
    End If 'oBlkRef.HasAttributes
    Next oBlkRef

    oSSet.Delete
    Set oSSet = Nothing
    Set oBlkRef = Nothing
    --
    John Goodfellow
    irtfnm
    use john at goodfellowassoc dot com


    without user direction or input. How do I assign "BlkAttrib" a AcadBlockRef
    in an automated way?
     
    John Goodfellow, Aug 19, 2004
    #4
  5. kyheulon

    kyheulon Guest

    I'll try that... Thanks.
     
    kyheulon, Aug 19, 2004
    #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.
Similar Threads
There are no similar threads yet.
Loading...