将面域旋转成球体时出错,大虾帮忙改以下
<P>Const pi = 3.1415926<BR>Dim r As Double</P><P><BR> '绘制球体<BR> Public Sub drwPicture()<BR> Dim curves(0) As AutoCAD.AcadEntity<BR> Dim centerpoint(2) As Double<BR> r = 500<BR> centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0<BR> Set curves(0) = ModelSpace.AddCircle(centerpoint, r)<BR> <BR> </P>
<P> Dim object As Variant<BR> object = ModelSpace.AddRegion(curves)<BR> <BR> Dim solidObj As AutoCAD.Acad3DSolid<BR> <BR> Dim axisPt(2) As Double<BR> Dim axisDir(2) As Double<BR> axisPt(0) = 0: axisPt(1) = 0: axisPt(2) = 0<BR> axisDir(0) = 1: axisDir(0) = 0: axisDir(0) = 0<BR> engle = 45 * pi / 180<BR> solidObj = ModelSpace.AddRevolvedSolid(object(0), axisPt, axisDir, engle)</P>
<P>Dim newdirection(2) As Double<BR>newdirection(0) = 1: newdirection(1) = 0.5: newdirection(2) = 0.5<BR>ActiveViewport.Direction = newdirection<BR>ActiveViewport = ActiveViewport</P>
<P>Layers.Item(0).color = AutoCAD.AcColor.acBlue<BR>SendCommand ("_shademode" + vbCr + "_g" + vbCr)<BR>ZoomAll<BR>curves(0).Delete<BR> <BR> End Sub</P> 黑体的地方出错了,高手指点一下吧, <P>Dim curves(0) As AutoCAD.AcadEntity<BR> Dim centerpoint(2) As Double<BR> r = 500<BR> centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0<BR> Set curves(0) = ModelSpace.AddCircle(centerpoint, r)<BR> Dim object As Variant<BR> object = ModelSpace.AddRegion(curves)</P>
<P>这段程序创建了一个用于旋转的圆的截面吧,我查了一下VBA的例子,它用一个半圆做截面旋转就没有问题,原因我不清楚。所以我改成了下面这段程序</P>
<P>Dim curves(1) As AutoCAD.AcadEntity<BR> Dim centerpoint(2) As Double<BR> r = 500<BR> centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0</P>
<P> Set ModelSpace = ThisDrawing.ModelSpace<BR> Dim startAngle As Double<BR> Dim endAngle As Double<BR> radius = 500<BR> startAngle = 0<BR> endAngle = pi<BR> Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerpoint, radius, startAngle, endAngle)</P>
<P> Set curves(1) = ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)</P>
<P>下面就不会报错了。。。。</P>
<P>还有就是你的声明给的不全吧,什么Modelspace,SendCommand都没有声明。。。。。。下面删除曲线的程序你自己改吧。。。。。真是不知道为什么整圆不能使用。。。。。。<BR></P> <P>谢谢了按照你的方法已经成功解决了;</P>
<P>在cad里面好象是不能用整圆旋转,可能是旋转出的两部分相交于轴了;</P>
<P>但是只要轴线在圆以外就行了。</P>
<P>再次感谢你热心的帮助!</P> bihumanbu 发表于 2006-5-22 19:55
谢谢了按照你的方法已经成功解决了;
在cad里面好象是不能用整圆旋转,可能是旋转出的两部分相交于轴了;
...
你好! 你的圆转球体的代码可以共享下吗,我想将许多大小不一的圆一次性转球体, 谢谢!
页:
[1]