明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1445|回复: 2

[原创]帮忙找程序错误

[复制链接]
发表于 2003-12-30 10:59:00 | 显示全部楼层 |阅读模式
总出现编译错误:在该对象模块派生的对象模块中成员已存在。
我用的是李风华《的AutoCAD 2002/2000 VBA开发指南》,程序总是会出错。谢谢大家指教
Sub copyobjects()
'定义变量
Dim circleobject As AcadCircle
Dim cenpoint(0 To 2) As Double
Dim radius As Double
Dim polylineobject As AcadLWPolyline
Dim plinevect(0 To 7) As Double

Dim cirobjectcopy As AcadCircle
Dim plineobjectcopy As AcadLWPolyline
Dim radiuscopy As Double

Dim objectcollection(0 To 1) As Object
Dim retobjects As Variant
Dim mspoint(0 To 2) As Double
Dim mepoint(0 To 2) As Double
'定义circle对象
cenpoint(0) = 0
cenpoint(1) = 0
cenpoint(2) = 0
radius = 6

plinevect(0) = 0
plinevect(1) = 0
plinevect(2) = 2
plinevect(3) = 5
plinevect(4) = 4
plinevect(5) = 7
plinevect(6) = 3
plinevect(7) = 12

'创建圆对象和多段线
Set circleobject = ThisDrawing.ModelSpace.AddCircle(cenpoint, radius)
Set polylineobject = ThisDrawing.ModelSpace.AddLightWeightPolyline(plinevect)

'将要复制的对象设置为与copyobjects兼容的形式
Set objectcollection(0) = circleobject
Set objectcollection(1) = polylineobject
'复制对象并返回新对象的集合
retobjects = ThisDrawing.copyobjects(objectcollection)
'取得新建的对象并套用新的属性到复制的对象

Set cirobjectcopy = retobject(0)
Set plineobjectcopy = retobject(1)
radiuscopy = 15
cenpoint(0) = 30
cenpoint(1) = 30
cenpoint(2) = 0
cirobjectcopy.radius = radiuscopy
cirobjectcopy.Center = cenpoint
cirobjectcopy.Linetype = "hidden"
cirobjectcopy.LinetypeScale = 0.5
mspoint(0) = 0
mspoint(1) = 0
mspoint(2) = 0
  mepoint(0) = 30
mepoint(1) = 30
mepoint(2) = 0
plineobjectcopy.Move mspoint, mepoint
plineobjectcopy.Linetype = "hidden"
plineobjectcopy.LinetypeScale = 0.5
ThisDrawing.Application.ZoomExtents

End Sub
发表于 2003-12-30 11:09:00 | 显示全部楼层
因为copyobjects是内部过程,你把Sub copyobjects()改成Sub copyobjects1()就可以了
 楼主| 发表于 2003-12-30 11:30:00 | 显示全部楼层
哦,对了。谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 10:42 , Processed in 0.161772 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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