View Full Version : Reading block attribute in closed drawing

11-02-2005, 12:21 PM

(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 :whistle:

11-02-2005, 10:01 PM
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,

11-08-2005, 02:13 PM
Ok, so what if i open the drawing....
is it easier to read a specific attribute of a block?
if so, how.

11-08-2005, 06:56 PM
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. :)

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")
Set ssetA = ThisDrawing.SelectionSets.Add("TEXTFILE")
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
Set ssetA = Nothing
End Sub

11-10-2005, 12:44 PM
This one will find the Attributes in the drawing itself, doesn't look at blocks. :)

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
End Sub

11-14-2005, 01:57 PM
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.

11-14-2005, 02:15 PM
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. :)

11-18-2005, 10:26 AM
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...