[求助]一个简单的创建六边形 面域的程序
高手看看,以下程序为什么有错误?我很迷惑!<BR>'创建六边形<BR>Dim objPline As AcadLWPolyline 'acadpolyline<BR>Dim ptCen(0 To 2) As Double<BR>ptCen(0) = 0: ptCen(1) = 0: ptCen(2) = 0
myCAD.Visible = True
<BR>Dim NumPoly As Integer '多边形的边数<BR>Dim RadiPoly As Double '多边形的半径
NumPoly = InputBox("多边形的数量:", "参数输入", 6)<BR>RadiPoly = InputBox("多边形的半径:", "参数输入", 30)
<BR>''''''''%%%%%%%%%%%%%%%%%%%%%%%<BR>Dim objLine As AcadLine<BR>Dim SP(0 To 2) As Double<BR>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
<BR>For I = 0 To NumPoly - 1
If I <> NumPoly - 1 Then<BR> SP(0) = ptCenX + RadiPoly * Cos(I * rad_Seg)<BR> SP(1) = ptCenY + RadiPoly * Sin(I * rad_Seg)<BR> SP(2) = ptCenZ + 0<BR> EP(0) = ptCenX + RadiPoly * Cos((I + 1) * rad_Seg)<BR> EP(1) = ptCenY + RadiPoly * Sin((I + 1) * rad_Seg)<BR> EP(2) = ptCenZ + 0
Set myCurves(I) = myMOS.AddLine(SP, EP)<BR> <BR> Else<BR> <BR> SP(0) = ptCenX + RadiPoly * Cos(I * rad_Seg)<BR> SP(1) = ptCenY + RadiPoly * Sin(I * rad_Seg)<BR> SP(2) = ptCenZ + 0<BR> EP(0) = ptCenX + RadiPoly<BR> EP(1) = ptCenY<BR> EP(2) = ptCenZ + 0
Set myCurves(I) = myMOS.AddLine(SP, EP)<BR> <BR> End If<BR> <BR> Debug.Print I & " X:" & SP(0) & " Y:" & SP(1) & " Z:" & SP(2)<BR> Debug.Print I & " X:" & EP(0) & " Y:" & EP(1) & " Z:" & EP(2)
<BR>Next I
''''''''%%%%%%%%%%%%%%%%%%%%%%%
'创建面域
'以上部分都是成功的!!
<BR>Dim objRegion As Variant<BR>Set objRegion = myMOS.AddRegion(myCurves) '本句为甚么总是提示 :实时错误13
'类型不匹配
'高手看看,很郁闷呀
<BR> 对了,上面的程序段中的 myMOS为一个当前的活动文档的模型空间。
页:
[1]