我查阅了太多使用GetAttributes的人的例子,弄不清是怎么回事……帮助文件似乎对我也没什么帮助
下面是我到目前为止的代码
我将用于此表的块中有3或4个属性,这些属性保存将传递给此表的信息
标记:
ID
ELEVATION
DATUMLOC
DESC
我需要获取每个单独属性/标记的值,并将其输出到一个表格单元格,正如您所示,我是如何使用xStr和yStr的。
Option Explicit
Sub Blocks_Table()
Dim oSset As AcadSelectionSet
Dim oEnt As AcadEntity
Dim oBlk As AcadBlockReference
Dim varPt As Variant
Dim ftype(0) As Integer
Dim fdata(0) As Variant
Dim bName As String
Dim Atts As Variant
Dim xStr As String
Dim yStr As String
Dim ID As String
Dim Desc As String
Dim i As Long, j As Long
ftype(0) = 0: fdata(0) = "INSERT"
Dim dxfCode, dxfValue
dxfCode = ftype: dxfValue = fdata
With ThisDrawing.SelectionSets
While .Count > 0
.Item(0).Delete
Wend
Set oSset = .Add("$Blocks$")
End With
ThisDrawing.ActivePViewport.Display True
ThisDrawing.ActiveSpace = acModelSpace
oSset.SelectOnScreen dxfCode, dxfValue
ThisDrawing.ActiveSpace = acPaperSpace
Dim paSpace As AcadPaperSpace
Set paSpace = ThisDrawing.PaperSpace
varPt = ThisDrawing.Utility.GetPoint(, vbCrLf & "Specify insertion point: ")
Dim oTable As AcadTable
Set oTable = paSpace.AddTable(varPt, oSset.Count + 3, 6, 0.3, 1.5)
oTable.TitleSuppressed = False
oTable.HeaderSuppressed = True
ZoomExtents
With oTable
.RegenerateTableSuppressed = True
.SetCellTextHeight i, j, 0.15625
.SetCellAlignment i, j, acMiddleCenter
.SetCellType i, j, acTextCell
.SetText 0, 0, "EQUIPMENT LAYOUT SCHEDULE"
.SetText 1, 0, "ITEM"
.SetCellTextHeight 1, 0, 0.09375
.SetText 1, 1, "EQUIPMENT DATUM"
.SetCellTextHeight 1, 1, 0.09375
.SetText 1, 4, "DATUM LOCATION"
.SetCellTextHeight 1, 4, 0.09375
.SetText 1, 5, "DESCRIPTION"
.SetCellTextHeight 1, 5, 0.09375
.SetText 2, 1, "N"
.SetCellTextHeight 2, 1, 0.09375
.SetText 2, 2, "E"
.SetCellTextHeight 2, 2, 0.09375
.SetText 2, 3, "EL"
.SetCellTextHeight 2, 3, 0.09375
For i = 0 To oSset.Count - 1
Set oEnt = oSset.Item(i)
Set oBlk = oEnt
If oBlk.IsDynamicBlock Then
bName = oBlk.EffectiveName
Else
bName = oBlk.Name
End If
xStr = Format(CStr(Round(oBlk.InsertionPoint(1), 3)), "#0.000")
yStr = Format(CStr(Round(oBlk.InsertionPoint(0), 3)), "#0.000")
.SetCellTextHeight i + 3, j, 0.09375
.SetCellAlignment i + 3, j, acMiddleCenter
.SetText i + 3, j, ID
.SetCellTextHeight i + 3, j, 0.09375
.SetText i + 3, j + 1, xStr
.SetCellTextHeight i + 3, j + 1, 0.09375
.SetText i + 3, j + 2, yStr
.SetCellTextHeight i + 3, j + 2, 0.09375
.SetText i + 3, j + 3, Desc
.SetCellTextHeight i + 3, j + 3, 0.09375
Next i
.RegenerateTableSuppressed = False
.Update
End With
oTable.MergeCells 1, 2, 0, 0
oTable.MergeCells 1, 2, 4, 4
oTable.MergeCells 1, 2, 5, 5
oTable.MergeCells 1, 1, 1, 3
MsgBox "Yahoooooo!"
End Sub
现在我还没有将值设置为ID或DESC,但我不确定如何执行此操作。 上传带有块的示例绘图
(删除未使用的信息和其他内容之前)
我明天会看
它〜'J'~
这里有一切必要的东西
从表面上看……我认为我的问题是,我不知道如何处理数组以获得测试所需的信息。dwg<br>在各种实例中包含模型空间中的块“基准”
我在例程中选择所有这些块,它切换到paperspace,请求表的插入点,然后创建它
我只是不知道如何获取属性的值,然后将它们放入表中<非常感谢您抽出时间! 菲索
是我获得最终完整代码的地方
如果你有意见、教训和建议,我很欢迎,但我不会再要求你为此花费时间了……你已经做了很多,我肯定要感谢你(和杰夫·M)!
页:
1
[2]