bihumanbu 发表于 2006-5-22 11:31:00

将面域旋转成球体时出错,大虾帮忙改以下

<P>Const pi = 3.1415926<BR>Dim r As Double</P>
<P><BR>&nbsp;'绘制球体<BR>&nbsp;Public Sub drwPicture()<BR>&nbsp;Dim curves(0) As AutoCAD.AcadEntity<BR>&nbsp;Dim centerpoint(2) As Double<BR>&nbsp;r = 500<BR>&nbsp;centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0<BR>&nbsp;Set curves(0) = ModelSpace.AddCircle(centerpoint, r)<BR>&nbsp;<BR>&nbsp;</P>
<P>&nbsp;Dim object As Variant<BR>&nbsp;object = ModelSpace.AddRegion(curves)<BR>&nbsp;<BR>&nbsp;Dim solidObj As AutoCAD.Acad3DSolid<BR>&nbsp;<BR>&nbsp;Dim axisPt(2) As Double<BR>&nbsp;Dim axisDir(2) As Double<BR>&nbsp;axisPt(0) = 0: axisPt(1) = 0: axisPt(2) = 0<BR>&nbsp;axisDir(0) = 1: axisDir(0) = 0: axisDir(0) = 0<BR>&nbsp;engle = 45 * pi / 180<BR>&nbsp;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>&nbsp;<BR>&nbsp;End Sub</P>

bihumanbu 发表于 2006-5-22 12:00:00

黑体的地方出错了,高手指点一下吧,

xinghesnak 发表于 2006-5-22 14:12:00

<P>Dim curves(0) As AutoCAD.AcadEntity<BR>&nbsp;Dim centerpoint(2) As Double<BR>&nbsp;r = 500<BR>&nbsp;centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0<BR>&nbsp;Set curves(0) = ModelSpace.AddCircle(centerpoint, r)<BR>&nbsp;Dim object As Variant<BR>&nbsp;object = ModelSpace.AddRegion(curves)</P>
<P>这段程序创建了一个用于旋转的圆的截面吧,我查了一下VBA的例子,它用一个半圆做截面旋转就没有问题,原因我不清楚。所以我改成了下面这段程序</P>
<P>Dim curves(1) As AutoCAD.AcadEntity<BR>&nbsp;Dim centerpoint(2) As Double<BR>&nbsp;r = 500<BR>&nbsp;centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0</P>
<P>&nbsp;Set ModelSpace = ThisDrawing.ModelSpace<BR>&nbsp;Dim startAngle As Double<BR>&nbsp;Dim endAngle As Double<BR>&nbsp;radius = 500<BR>&nbsp;startAngle = 0<BR>&nbsp;endAngle = pi<BR>&nbsp;Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerpoint, radius, startAngle, endAngle)</P>
<P>&nbsp;Set curves(1) = ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)</P>
<P>下面就不会报错了。。。。</P>
<P>还有就是你的声明给的不全吧,什么Modelspace,SendCommand都没有声明。。。。。。下面删除曲线的程序你自己改吧。。。。。真是不知道为什么整圆不能使用。。。。。。<BR></P>

bihumanbu 发表于 2006-5-22 19:55:00

<P>谢谢了按照你的方法已经成功解决了;</P>
<P>在cad里面好象是不能用整圆旋转,可能是旋转出的两部分相交于轴了;</P>
<P>但是只要轴线在圆以外就行了。</P>
<P>再次感谢你热心的帮助!</P>

guosheyang 发表于 2018-4-27 15:48:33

bihumanbu 发表于 2006-5-22 19:55
谢谢了按照你的方法已经成功解决了;
在cad里面好象是不能用整圆旋转,可能是旋转出的两部分相交于轴了;
...

你好! 你的圆转球体的代码可以共享下吗,我想将许多大小不一的圆一次性转球体, 谢谢!
页: [1]
查看完整版本: 将面域旋转成球体时出错,大虾帮忙改以下