明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2124|回复: 1

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

[复制链接]
发表于 2006-4-21 08:37:00 | 显示全部楼层 |阅读模式

代码如下:加下划线的地方提示类型不匹配,为什么?二天都没找到原因啊。

Private Sub UserForm_Click()
Dim aa As AcadPolyline
Me.hide
Dim entobj As AcadEntity
Dim coorpoint As Variant
Dim coorpoint1 As Variant
Dim pickpoint As Variant
ThisDrawing.Utility.GetEntity entobj, pickpoint, "请选择闭合多段线"
If StrComp(entobj.ObjectName, "acdbpolyline", 1) = 0 And entobj.Closed = True Then
a = entobj.Area
TextBox1.Text = a
coorpoint = entobj.Coordinates
Else
MsgBox "不是多段线或没有闭合,请检查"
Exit Sub
End If

Dim n As Integer, m As Integer
n = UBound(coorpoint)
m = (n + 1) * 3 / 2 - 1
TextBox2.Text = n

For I = 0 To n Step 2
[U][U]coorpoint1(I * 3 / 2) = coorpoint(I)[/U]

coorpoint1(I * 3 / 2 + 1) = coorpoint(I + 1)
'coorpoint1(I + 2) = 0
Next I

 'TextBox2.Text = coorpoint1(5)
Dim sset As AcadSelectionSet

    On Error Resume Next
    If ThisDrawing.SelectionSets.Count <> 0 Then
        For j = 0 To ThisDrawing.SelectionSets.Count - 1
            Set sset = ThisDrawing.SelectionSets(I)
            sset.Delete
        Next
    End If
Set sset = ThisDrawing.SelectionSets.Add("4")
mode = acSelectionSetCrossingPolygon
'mode = acSelectionSetWindowPolygon
filtertype = 0
filterdata = "text"
sset.SelectByPolygon mode, coorpoint1, filtertype, filterdata
'sset.SelectOnScreen
Dim entry As AcadEntity
For Each entry In sset
entry.Color = acBlue
entry.updata
Next entry
 Me.Show
End Sub

发表于 2006-4-21 16:02:00 | 显示全部楼层

因为 你只有写了 Dim coorpoint1 As Variant

而中途你改动了coorpoint = entobj.Coordinates

coorpoint 就变成数组了 当然类型不匹配

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 04:27 , Processed in 0.164312 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表