bjbjbjbj 发表于 2006-4-21 08:37:00

(求救)刚学VBA,提取PLINE闭合线顶点坐标为3维坐标时提示类型不匹配

<P>代码如下:加下划线的地方提示类型不匹配,为什么?二天都没找到原因啊。</P>
<P>Private Sub UserForm_Click()<BR>Dim aa As AcadPolyline<BR>Me.hide<BR>Dim entobj As AcadEntity<BR>Dim coorpoint As Variant<BR>Dim coorpoint1 As Variant<BR>Dim pickpoint As Variant<BR>ThisDrawing.Utility.GetEntity entobj, pickpoint, "请选择闭合多段线"<BR>If StrComp(entobj.ObjectName, "acdbpolyline", 1) = 0 And entobj.Closed = True Then<BR>a = entobj.Area<BR>TextBox1.Text = a<BR>coorpoint = entobj.Coordinates<BR>Else<BR>MsgBox "不是多段线或没有闭合,请检查"<BR>Exit Sub<BR>End If</P>
<P>Dim n As Integer, m As Integer<BR>n = UBound(coorpoint)<BR>m = (n + 1) * 3 / 2 - 1<BR>TextBox2.Text = n</P>
<P>For I = 0 To n Step 2<BR>coorpoint1(I * 3 / 2) = coorpoint(I)</P>
<P>coorpoint1(I * 3 / 2 + 1) = coorpoint(I + 1)<BR>'coorpoint1(I + 2) = 0<BR>Next I</P>
<P>&nbsp;'TextBox2.Text = coorpoint1(5)<BR>Dim sset As AcadSelectionSet</P>
<P>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; If ThisDrawing.SelectionSets.Count &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For j = 0 To ThisDrawing.SelectionSets.Count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sset = ThisDrawing.SelectionSets(I)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sset.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; End If<BR>Set sset = ThisDrawing.SelectionSets.Add("4")<BR>mode = acSelectionSetCrossingPolygon<BR>'mode = acSelectionSetWindowPolygon<BR>filtertype = 0<BR>filterdata = "text"<BR>sset.SelectByPolygon mode, coorpoint1, filtertype, filterdata<BR>'sset.SelectOnScreen<BR>Dim entry As AcadEntity<BR>For Each entry In sset<BR>entry.Color = acBlue<BR>entry.updata<BR>Next entry<BR>&nbsp;Me.Show<BR>End Sub<BR></P>

68651521 发表于 2006-4-21 16:02:00

<P>因为 你只有写了 Dim coorpoint1 As Variant</P>
<P>而中途你改动了coorpoint = entobj.Coordinates</P>
<P>coorpoint 就变成数组了 当然类型不匹配</P>
页: [1]
查看完整版本: (求救)刚学VBA,提取PLINE闭合线顶点坐标为3维坐标时提示类型不匹配