块内实体的修改?
<P>又麻烦各位了!</P><P> 已经建立一个块,并在图中插入,前面的程序省略,执行正常,但当我执行一个块内某直线位置的修改时出了问题: </P>
<P>For Each Bobj In ThisDrawing.Blocks(Bname)<BR> If Bobj.ObjectName = "AcDbLine" Then<BR> Bobj.Color = acGreen '改为绿色<BR> Bobj.Move pt1, pt2<BR> End If<BR> Next<BR></P>
<P>上面的代码都很正常,但 Bobj.Move pt1, pt2 无法执行,提示为“无法调用的过各或参数”</P>
<P>而且直接修改该直线的起点和端点座标也不行。</P> 应该没问题的,可能是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 OK,谢谢!犯了点低级错误,PT1和PT2的声明不对, 由于要移动的距离是固定的数值,不需要在屏幕上去选择,所以把声明改为double的数组就行了。
页:
[1]