singlegu 发表于 2006-5-31 13:42:00

关于三维旋转的程序,有点问题,大家来帮我看看啊!!!

<P>我生成一个圆环面域,想让它绕着Y轴旋转90度,程序如下,大家帮我改改啊</P>
<P>Sub Example_Rotate3D()</P>
<P>&nbsp; Dim circle1(0) As AcadEntity<BR>&nbsp;&nbsp; Dim circle2(0) As AcadEntity<BR>&nbsp;&nbsp; Dim regionObj1 As Variant<BR>&nbsp;&nbsp; Dim regionObj2 As Variant<BR>&nbsp;&nbsp; Dim point1(0 To 2) As Double<BR>&nbsp;&nbsp; Dim radius1 As Double<BR>&nbsp;&nbsp; Dim radius2 As Double<BR>&nbsp;&nbsp; Dim solidObj As Acad3DSolid<BR>&nbsp;&nbsp; Dim polyObj As Acad3DPolyline<BR>&nbsp;&nbsp; radius1 = 15<BR>&nbsp;&nbsp; radius2 = 10<BR>&nbsp;&nbsp; point1(0) = 0<BR>&nbsp;&nbsp; point1(1) = -50<BR>&nbsp;&nbsp; point1(2) = 0<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; '创建面域<BR>&nbsp;&nbsp; Set circle1(0) = ThisDrawing.ModelSpace.AddCircle(point1, radius1)<BR>&nbsp;&nbsp; Set circle2(0) = ThisDrawing.ModelSpace.AddCircle(point1, radius2)<BR>&nbsp;&nbsp; regionObj1 = ThisDrawing.ModelSpace.AddRegion(circle1)<BR>&nbsp;&nbsp; regionObj2 = ThisDrawing.ModelSpace.AddRegion(circle2)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; '布尔运算<BR>&nbsp;&nbsp; regionObj1(0).Boolean acSubtraction, regionObj2(0)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; '三维旋转<BR>&nbsp;&nbsp; Dim point2(0 To 2) As Double<BR>&nbsp;&nbsp; Dim point3(0 To 2) As Double<BR>&nbsp;&nbsp; Dim rotateAngle As Double<BR>&nbsp;&nbsp; rotateAngle = 90 * 3.141592 / 180#<BR>&nbsp;&nbsp; point2(0) = 0<BR>&nbsp;&nbsp; point2(1) = 0<BR>&nbsp;&nbsp; point2(2) = 0<BR>&nbsp;&nbsp; point3(0) = 0<BR>&nbsp;&nbsp; point3(1) = -50<BR>&nbsp;&nbsp; point3(2) = 0<BR>&nbsp;&nbsp; regionObj1.Rotate3D point2, point3, rotateAngle//这句有问题,说是"要求对象"<BR>&nbsp;&nbsp; ThisDrawing.Regen True</P>
<P>End Sub<BR></P>文字

xinghesnak 发表于 2006-5-31 15:58:00

<P>姐姐,怎么又是你啊,你的程序还有问题啊。。。。。</P>
<P>1,regionobj1是个数组,没有Rotate3D的属性,所以要选定数组里的一个对象才行</P>
<P>2。作为旋转轴的线段事先要创建好才行,不能凭空指定两点</P>
<P>所以把你这句regionObj1.Rotate3D point2, point3, rotateAngle 改成</P>
<P>ThisDrawing.ModelSpace.AddLine point2, point3<BR>&nbsp;&nbsp; regionObj1(0).Rotate3D point2, point3, rotateAngle</P>
<P>就行了!</P>

singlegu 发表于 2006-6-1 09:40:00

<P>大哥,那我怎么样才能使最后只保留旋转后的面域呢,之前的面域和旋转轴都不要显示</P>

xinghesnak 发表于 2006-6-1 10:58:00

<P>&nbsp;&nbsp; Dim Line1 As AcadLine<BR>&nbsp;&nbsp; Set Line1 = ThisDrawing.ModelSpace.AddLine(point2, point3)<BR>&nbsp;&nbsp; regionObj1(0).Rotate3D point2, point3, rotateAngle</P>
<P>&nbsp;&nbsp; circle1(0).Visible = False<BR>&nbsp;&nbsp; circle2(0).Visible = False<BR>&nbsp;&nbsp; Line1.Visible = False</P>
<P>&nbsp;&nbsp; ThisDrawing.Regen True</P>
<P>更正你一下,旋转完面域后原来的面域位置就是两个圆存在,不是面域。。。。。</P>
页: [1]
查看完整版本: 关于三维旋转的程序,有点问题,大家来帮我看看啊!!!