选择集中的点转成数组后出现的问题?
<P>选择集中的点转成数组后出现的问题?源程序如下:</P><P>Sub mm()<BR> On Error Resume Next<BR> Dim sset As AcadSelectionSet<BR> Dim objcir As AcadCircle<BR> Dim radius As Double<BR> <BR> Dim filtertype(0) As Integer<BR> Dim filterdata(0) As Variant<BR> <BR> If Not IsNull(ThisDrawing.SelectionSets.Item("Circles")) Then<BR> Set sset = ThisDrawing.SelectionSets.Item("Circles")<BR> sset.Delete<BR> End If<BR> Set sset = ThisDrawing.SelectionSets.Add("Circles")<BR> <BR> filtertype(0) = 0 '设置选择过滤器<BR> filterdata(0) = "circle"<BR> <BR> sset.SelectOnScreen filtertype, filterdata<BR> Dim ptarr()<BR> Dim count As Integer<BR> count = sset.count<BR> ReDim ptarr(count - 1)<BR> For Each objcir In sset<BR> <BR> Dim ptcen As Variant<BR> ptcen = objcir.Center<BR> Dim i As Integer<BR> For i = 0 To count - 1<BR> Dim cir1 As AcadCircle<BR> Set cir1 = sset.Item(i)<BR> cir1.Center = ptarr(i)<BR> Next i<BR> Next<BR> Dim pt1 As Variant<BR> pt1 = ptarr(0)<BR> MsgBox pt1(0)<BR> MsgBox pt1(1)<BR> <BR>End Sub</P>
<P>运行后无任何反应!</P> <P>ReDim ptarr(count - 1,2)<BR>dim ii,i as Integer </P>
<P>ii=0</P>
<P>i=0 </P>
<P>For Each objcir In sset<BR> <BR> Dim ptcen As Variant<BR> ' ptcen = objcir.Center</P>
<P> Set ptcen = objcir.Center<BR> For i = 0 To 2</P>
<P>ptarr(ii,i)=ptcen(i)<BR> Next i</P>
<P>ii=ii+1<BR> Next<BR>改成这样试试</P> <P>先谢谢!</P>
<P>还是不行</P>
<P>Dim x As Double<BR> Dim y As Double<BR> x = ptarr(0, 0)<BR> y = ptarr(0, 1)<BR> MsgBox x<BR> MsgBox y</P>
<P>任何时候显示为0,0</P>
<P> </P> ReDim ptarr(sset.count - 1)
For i= 0 to sset.count-1
ptarr(i)=sset(i).Center
Next
msgbox ptarr(0)(0) & "," & ptarr(0)(1) & "," & ptarr(0)(2)
页:
[1]