Consulting

Results 1 to 8 of 8

Thread: Reading block attribute in closed drawing

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location

    Reading block attribute in closed drawing

    Question,

    (in relating to the previous postings of pagesetups) is there a way to read an invisible attribute from a block in a closed drawing...

    ill explain.
    im in a NEW drawing "A". And drawing XR-TITLE, has a block in it (call it XR-TB) with an invisible attribute that defines what size of paper to use (say 24x36)....

    can i read the attribute of that block in the closed drawing from my open drawing "A"... so i can determine what size title border to insert into my current drawing...

    Thanks for any help.
    ccastelein

  2. #2
    VBAX Regular
    Joined
    Nov 2005
    Posts
    10
    Location

    ...

    There is a way, and it's based on knowing the drawing format key so to speak, which is being pushed for open availability, the state of which is not known by me, subsequent formats were released for versions prior to whatever is the current version, others have be reverse engineered. it is how microstation opens a version of an AutoCAD drawing, currently they pay Autodesk for the info I think...

    These guys provide tools and support for what you are looking for. If you find anything, please report it, it is something I have wanted to do to,
    www.opendesign.com

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    Ok, so what if i open the drawing....
    is it easier to read a specific attribute of a block?
    if so, how.
    ccastelein

  4. #4
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    This will get all blockref's in the open drawing, and msgbox some Attributes, I didn't know what you wanted or what you wanted to do.

    [VBA]
    Sub FindBlockAttributes()
    Dim mI As Long, mBlkRef As AcadBlockReference
    Dim mInfo As AcadAttribute
    Dim mTemp As Variant
    Dim pt(1), pt1(1)
    Dim groupCode As Variant, dataCode As Variant
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    Dim ssetA As AcadSelectionSet
    On Error Resume Next
    Set ssetA = ThisDrawing.SelectionSets.Add("TEXTFILE")
    If Err.Number <> 0 Then
    Set ssetA = ThisDrawing.SelectionSets("TEXTFILE")
    ssetA.Delete
    Set ssetA = ThisDrawing.SelectionSets.Add("TEXTFILE")
    Err.Clear
    End If
    gpCode(0) = 0
    dataValue(0) = "Insert"
    groupCode = gpCode
    dataCode = dataValue
    AcadApplication.Visible = acTrue
    ThisDrawing.Regen acActiveViewport
    pt(0) = ThisDrawing.Limits(0): pt(1) = ThisDrawing.Limits(1)
    pt1(0) = ThisDrawing.Limits(2): pt1(1) = ThisDrawing.Limits(3)
    ssetA.Select acSelectionSetAll, pt, pt1, groupCode, dataCode
    For Each mBlkRef In ssetA
    mTemp = mBlkRef.GetAttributes
    For mI = LBound(mTemp) To UBound(mTemp)
    MsgBox mTemp(mI).Color
    MsgBox mTemp(mI).TextString
    MsgBox mTemp(mI).Alignment
    MsgBox mTemp(mI).Backward
    MsgBox mTemp(mI).Constant
    MsgBox mTemp(mI).FieldLength
    MsgBox mTemp(mI).Height
    MsgBox mTemp(mI).TagString
    Next
    Next
    ssetA.Delete
    Set ssetA = Nothing
    End Sub

    [/VBA]

  5. #5
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    This one will find the Attributes in the drawing itself, doesn't look at blocks.

    [VBA]
    Sub FindAttributes()
    Dim mI As Long
    Dim mInfo As AcadAttribute
    For mI = 0 To ThisDrawing.ModelSpace.Count - 1
    If TypeOf ThisDrawing.ModelSpace(mI) Is AcadAttribute Then
    MsgBox ThisDrawing.ModelSpace(mI).TagString
    MsgBox ThisDrawing.ModelSpace(mI).PromptString
    End If
    Next
    End Sub

    [/VBA]

  6. #6
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    tommy,
    im very interested in the above...
    i slapped that code into mine, and ran it and nothing happened...
    one of 3 things happend..
    either it doesnt work, or there are no attributes in/of the drawing, or i did something wrong...

    im strongly leaning towards the latter two... heh.
    any ideas? what exactly are the "attributes in the drawing itself"
    thanks again.
    ccastelein
    Last edited by ccastelein; 11-14-2005 at 01:58 PM. Reason: forgot to review it

  7. #7
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    If nothing happened it is because there were no attributes there. I used a drawing that I insert that asks for reactions and such. It has about 7 questions prompts. These are the attributes in an inserted block. Which are attributes in the original drawing. The attachment has the file I tested/developed on. Let me know how it goes.

  8. #8
    VBAX Regular
    Joined
    Nov 2005
    Posts
    10
    Location
    You may also need to ask the block if it has attributes first, for some reason, in earlier releases, the was a bug in accessing attributes in blocks that did not have prior function to if block.hasattributes
    from acad help, hasattributes property:
    This property is TRUE if the block reference contains any editable or constant (non-editable) attributes. It is FALSE if there are no attributes.
    so this makes me wonder about invisible ones...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •