明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1601|回复: 1

[求助]一个简单的创建六边形 面域的程序

[复制链接]
发表于 2004-4-14 14:11:00 | 显示全部楼层 |阅读模式
高手看看,以下程序为什么有错误?我很迷惑!
'创建六边形
Dim objPline As AcadLWPolyline 'acadpolyline
Dim ptCen(0 To 2) As Double
ptCen(0) = 0: ptCen(1) = 0: ptCen(2) = 0 myCAD.Visible = True
Dim NumPoly As Integer '多边形的边数
Dim RadiPoly As Double '多边形的半径 NumPoly = InputBox("多边形的数量:", "参数输入", 6)
RadiPoly = InputBox("多边形的半径:", "参数输入", 30)
''''''''%%%%%%%%%%%%%%%%%%%%%%%
Dim objLine As AcadLine
Dim SP(0 To 2) As Double
Dim EP(0 To 2) As Double Dim rad_Seg As Double Dim myCurves() As AcadEntity ReDim myCurves(0 To NumPoly - 1) As AcadEntity rad_Seg = 2 * PI / NumPoly ptCenX = 0: ptCenY = 0: ptCenZ = 0
For I = 0 To NumPoly - 1 If I <> NumPoly - 1 Then
SP(0) = ptCenX + RadiPoly * Cos(I * rad_Seg)
SP(1) = ptCenY + RadiPoly * Sin(I * rad_Seg)
SP(2) = ptCenZ + 0
EP(0) = ptCenX + RadiPoly * Cos((I + 1) * rad_Seg)
EP(1) = ptCenY + RadiPoly * Sin((I + 1) * rad_Seg)
EP(2) = ptCenZ + 0 Set myCurves(I) = myMOS.AddLine(SP, EP)

Else

SP(0) = ptCenX + RadiPoly * Cos(I * rad_Seg)
SP(1) = ptCenY + RadiPoly * Sin(I * rad_Seg)
SP(2) = ptCenZ + 0
EP(0) = ptCenX + RadiPoly
EP(1) = ptCenY
EP(2) = ptCenZ + 0 Set myCurves(I) = myMOS.AddLine(SP, EP)

End If

Debug.Print I & " X:" & SP(0) & " Y:" & SP(1) & " Z:" & SP(2)
Debug.Print I & " X:" & EP(0) & " Y:" & EP(1) & " Z:" & EP(2)
Next I ''''''''%%%%%%%%%%%%%%%%%%%%%%% '创建面域 '以上部分都是成功的!!
Dim objRegion As Variant
Set objRegion = myMOS.AddRegion(myCurves) '本句为甚么总是提示 :实时错误13 '类型不匹配 '高手看看,很郁闷呀
 楼主| 发表于 2004-4-14 14:14:00 | 显示全部楼层
对了,上面的程序段中的 myMOS为一个当前的活动文档的模型空间。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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