dfgs 发表于 2005-10-31 14:59:00

块内实体的修改?

<P>又麻烦各位了!</P>
<P>  已经建立一个块,并在图中插入,前面的程序省略,执行正常,但当我执行一个块内某直线位置的修改时出了问题:&nbsp; </P>
<P>For Each Bobj In ThisDrawing.Blocks(Bname)<BR>&nbsp;&nbsp;&nbsp;&nbsp; If Bobj.ObjectName = "AcDbLine" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bobj.Color = acGreen&nbsp; '改为绿色<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bobj.Move pt1, pt2<BR>&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp; Next<BR></P>
<P>上面的代码都很正常,但&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bobj.Move pt1, pt2  无法执行,提示为“无法调用的过各或参数”</P>
<P>而且直接修改该直线的起点和端点座标也不行。</P>

alin 发表于 2005-10-31 20:05:00

应该没问题的,可能是pt1和pt2不对,完了还要Regen
Sub test()
Dim pt1 As Variant
Dim pt2 As Variant
pt1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "First point:")
pt2 = ThisDrawing.Utility.GetPoint(pt1, vbCrLf & "Second point:")
For Each Bobj In ThisDrawing.Blocks("aaa")
   If Bobj.ObjectName = "AcDbLine" Then
       Bobj.color = acGreen'改为绿色
       Bobj.Move pt1, pt2
   End If
Next
ThisDrawing.Regen acActiveViewport
End Sub

dfgs 发表于 2005-10-31 20:20:00

OK,谢谢!犯了点低级错误,PT1和PT2的声明不对, 由于要移动的距离是固定的数值,不需要在屏幕上去选择,所以把声明改为double的数组就行了。
页: [1]
查看完整版本: 块内实体的修改?