szuki 发表于 2009-10-27 08:43:00

[求助] 如何获得属性块的属性并修改某个值?

<p>Public Sub Add_Block1()</p><p>Dim dblStart(0 To 2) As Double&nbsp; '插入点<br/>Dim objBlkDef As AcadBlock<br/>Dim objBlkRef As AcadBlockReference<br/>Dim objBlock As AcadBlock</p><p>For Each objBlock In ThisDrawing.Blocks<br/>&nbsp;&nbsp;&nbsp; If objBlock.Name = "Block1" Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '找到指定的块<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objBlkDef = ThisDrawing.Blocks.Item("OrderBlock")<br/>&nbsp;&nbsp;&nbsp; End If<br/>Next</p><p><font color="#ff0000">'objBlkDef 如何转换为objBlkRef呢?</font></p><p>Dim varAttributes As Variant<br/>varAttributes = objBlkRef.GetAttributes<br/>varAttributes(0).TextString = "成功了"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '修改第一个属性值?</p><p>End Sub<br/></p>

雪山飞狐_lzh 发表于 2009-10-27 13:40:00

<p>用选择集过滤相应块名的块参照</p><p>Blocks是块定义集合而不是块参照集合<br/></p>

szuki 发表于 2009-10-27 18:00:00

<p>如何写程序呢?</p><p>刚开始学cad的vba,需要大侠帮忙</p>

szuki 发表于 2009-11-3 12:08:00

继续等大侠帮忙。。

home 发表于 2009-11-3 17:13:00

Set objBlkRef = ThisDrawing.ModelSpace.InsertBlock(InsertionPoint, "Block1", 1, 1, 1, 0)

szuki 发表于 2009-11-3 18:22:00

这是直接引用啊,我需要或者已经存在的块的属性。。。

home 发表于 2009-11-6 11:53:00

Dim ent As AcadEntity<br/>For Each ent In ThisDrawing.ModelSpace<br/>&nbsp;&nbsp;&nbsp; If ent.Name = "Block1" Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '找到指定的块<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objBlkRef = ent<br/>&nbsp;&nbsp;&nbsp; End If<br/>Next

szuki 发表于 2009-11-6 13:55:00

Set objBlkRef = ent      这句出错,   运行错误438,对象不支持该属性和方法。

szuki 发表于 2009-11-6 14:04:00

Set objBlkRef = ent   这句提示方法错

home 发表于 2009-11-6 15:06:00

我的怎么没有提示错误,
页: [1] 2
查看完整版本: [求助] 如何获得属性块的属性并修改某个值?