明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1745|回复: 1

[求助]AddLightWeightPolyline不能创建可变的多线段吗?

[复制链接]
发表于 2005-6-25 09:41:00 | 显示全部楼层 |阅读模式
Dim points(0 To 5) As Double

' 为二维多段线顶点赋值
points(0) = 2: points(1) = 4
points(2) = 4: points(3) = 2
points(4) = 6: points(5) = 4

Set plineObj = doc1.ModelSpace.AddLightWeightPolyline(points)

上面的没有任何问题

但如果我有一个字符串如下:
dim objstr as string=
"0,0|740.4857,0|740.4857,-89.8498|0,-89.8498"
通过objstr创建一个多线段,怎么老是出错呢?

'db是ado的一个记录集 dim db as new adodb.recordset

Dim points
dim objsum,i as integer

objstr = Replace(objstr, "|", ",")
points = Split(objstr, ",")
objsum = db("summit_sum") * 2 - 1 'db("summit_sum") 是多线段的顶点个数

ReDim repoints(0 To objsum) As double
'ReDim repoints(0 To objsum) As variant 这两种定义方式都不行
''ReDim repoints(0 To objsum)

For i = 0 To objsum
repoints(i) = points(i)
Debug.Print points(i)
Next

Set plineObj = doc1.ModelSpace.AddLightWeightPolyline(points)
'这一句添加时老是出错:无效的过程调用或参数
'我试了上面好几种定义方式都不行,
发表于 2005-6-25 17:49:00 | 显示全部楼层
可以啊. 看看我的示例:i为可输入的大于等于3的奇数,Pvar通过循环付值 Sub test()
Dim Pvar As Variant
Dim Pline Dim j
i = 3
ReDim Pvar(0 To i) As Double 'For j=0 To i
Pvar(0) = 0: Pvar(1) = 0
Pvar(2) = 100: Pvar(3) = 100 'Next
Set Pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(Pvar) End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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