紫色狂澜 发表于 2009-4-17 21:54:00

[求助]如何在为已有块添加属性后自动更新?

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

雪山飞狐_lzh 发表于 2009-4-18 09:41:00

<p>删掉块引用,重新插入一遍</p>

紫色狂澜 发表于 2009-4-18 10:47:00

呵呵<div>多谢飞狐斑竹:)</div><div>我试下先</div><div>有没办法不重新插入就可以自动同步啊?</div>
页: [1]
查看完整版本: [求助]如何在为已有块添加属性后自动更新?