本帖最后由 作者 于 2009-4-17 21:57:02 编辑
因工作需要我想给一张图原有块添加相关属性 下面代码给名为TestBlock的块添加一个属性
Sub blockTest() Dim blockObj As AcadBlock Dim attObj As AcadAttribute Dim i As Integer ' Define the attribute definition Dim attributeObj As AcadAttribute Dim height As Double Dim mode As Long Dim prompt As String Dim insertionPoint(0 To 2) As Double Dim tag As String Dim value As String height = 1# mode = acAttributeModeVerify prompt = "Attribute Prompt" insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0 tag = "Attribute Tag" value = "Attribute Value" ' Create the attribute definition object in model space
For i = 3 To ThisDrawing.Blocks.Count - 1 If (ThisDrawing.Blocks.Item(i).Name = "TestBlock") Then Set blockObj = ThisDrawing.Blocks.Item(i) Set attributeObj = blockObj.AddAttribute(height, mode, prompt, insertionPoint, tag, value) attributeObj.Update Exit Sub End If Next i End Sub
执行完上述代码后选中该块的一个块引用(block reference)查看其特性(properties)看不到刚添加的属性(Attribute) 如下图:
必须在“块属性管理器”中点“同步”后才行 请问如何才能用VBA实现为原有块添加属性后立即能从其块引用的特性(properties)里看到 即实现“块属性管理器”中点“同步”的功能?? 多谢!!
|