为什么这段程序会报未找到主键?
<p>我想找到一个BlockReference 然后更改它的NAME ,可到了最后一句总报未找到主键,魏森么呢?</p><p>Dim InsPoint(0 To 2) As Double<br/>Dim NewEnt As AcadBlockReference<br/>For Each Ent In ThisDrawing.ModelSpace<br/> If Ent.ObjectName = "AcDbBlockReference" Then<br/> Select Case Ent.Name 'EffectiveName<br/> Case "Motor_Cable"<br/> Set NewEnt = Ent.Copy<br/> <br/> Dim point1(0 To 2) As Double<br/> point1(0) = 2: point1(1) = 1: point1(2) = 0</p><p> <br/> NewEnt.InsertionPoint = point1<br/> <br/> End Select<br/> End If<br/> Next</p><p>NewEnt.Name = "MotorAAA" '这里报错</p><p>End Sub<br/>谢谢!!</p> <p>顶一下 期待回答 </p> <p>貌似思路不对,建新块,只能用blocks.add方法</p><p></p> <p>建新块也行,怎么能建一个新的把以前的那个所有信息都拷贝过来呢? 这些块只有编号不一样 图形什么的都一样啊</p> <p>你修改的应该是AcadBlock的name,AcadBlockReference的name是只读的</p><p>ThisDrawing.Blocks.Item(NewEnt.Name).Name = "MotorAAA" </p> <p class="body">BlockRef: A block reference can be assigned the name of only a valid block definition in the drawing. Assigning a block reference a unique name will not automatically create a new block definition. To create a new block definition, use the <a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/idh_add.htm">Add</a> method to add a new Block object to the Blocks collection. </p> 测试成功 太感谢了!!!!!!!!!!!!!!!
页:
[1]