vba旋转生成实体
求VBA旋转生成实体语句,如一个平面的圆绕一个轴旋转后生成圆环,就是这个图标的语句。谢了! <pre class="Code">Sub Example_AddRevolvedSolid()' 该示例通过面域沿一个轴旋转以创建实体。
' 面域是由一个弧和一根直线创建的。
Dim curves(0 To 1) As AcadEntity
' 定义圆弧
Dim centerPoint(0 To 2) As Double
Dim radius As Double
Dim startAngle As Double
Dim endAngle As Double
centerPoint(0) = 5#: centerPoint(1) = 3#: centerPoint(2) = 0#
radius = 2#
startAngle = 0
endAngle = 3.141592
Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
' 定义直线
Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).startPoint, curves(0).endPoint)
' 创建面域
Dim regionObj As Variant
regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
ZoomAll
MsgBox "旋转该面域以创建实体。", , "AddRevolvedSolid 示例"
' 定义旋转轴
Dim axisPt(0 To 2) As Double
Dim axisDir(0 To 2) As Double
Dim angle As Double
axisPt(0) = 7: axisPt(1) = 2.5: axisPt(2) = 0
axisDir(0) = 11: axisDir(1) = 1: axisDir(2) = 3
angle = 6.28
' 创建实体
Dim solidObj As Acad3DSolid
Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)
ZoomAll
' 更改视口的查看方向以更好地看清实体
Dim NewDirection(0 To 2) As Double
NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
ThisDrawing.ActiveViewport.direction = NewDirection
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
ZoomAll
MsgBox "实体已创建完成", , "AddRevolvedSolid 示例"
End Sub</pre> <p>谢了,就是这个东西,我的开发要完成了</p> <p>Sub Example_AddRevolvedSolid()<br/> Dim cc As AcadCircle<br/> Dim ptc(0 To 2) As Double<br/> Dim rc As Double<br/> ptc(0) = 0: ptc(1) = 0: ptc(2) = 0<br/> re = 5<br/> Set cc = ThisDrawing.ModelSpace.AddCircle(ptc, re)<br/> ' 创建面域<br/> Dim regionObj As Variant<br/> regionObj = ThisDrawing.ModelSpace.AddRegion(cc)<br/> <br/> <br/> ' 定义旋转轴<br/> Dim axisPt(0 To 2) As Double<br/> Dim axisDir(0 To 2) As Double<br/> Dim angle As Double<br/> axisPt(0) = 10: axisPt(1) = -5: axisPt(2) = 0<br/> axisDir(0) = 10: axisDir(1) = 5: axisDir(2) = 0<br/> angle = 6.28<br/> <br/> ' 创建实体<br/> Dim solidObj As Acad3DSolid<br/> Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)<br/> ZoomAll<br/>End Sub<br/>这又是这么回事?</p>
<p>按照你给的代码修改的</p> <p>求解答~~~~~~~~~~~~~~~~~~!!~!~!~!~!~!~!~!</p> 00000000000000000000000000 <p>版主,管理员。。。。。。。。帮忙解决下啊~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!!</p>
<p>谢谢~~~~~~~~~~~~~~~~~~!</p>
页:
[1]