明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1775|回复: 6

vba旋转生成实体

[复制链接]
发表于 2010-7-23 23:04:00 | 显示全部楼层 |阅读模式
求VBA旋转生成实体语句,如一个平面的圆绕一个轴旋转后生成圆环,就是这个图标的语句。谢了!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2010-7-28 22:54:00 | 显示全部楼层
<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>
 楼主| 发表于 2010-7-30 12:59:00 | 显示全部楼层

谢了,就是这个东西,我的开发要完成了

 楼主| 发表于 2010-7-30 13:26:00 | 显示全部楼层

Sub Example_AddRevolvedSolid()
        Dim cc As AcadCircle
        Dim ptc(0 To 2) As Double
        Dim rc As Double
        ptc(0) = 0: ptc(1) = 0: ptc(2) = 0
        re = 5
         Set cc = ThisDrawing.ModelSpace.AddCircle(ptc, re)
    ' 创建面域
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(cc)
  
   
    ' 定义旋转轴
    Dim axisPt(0 To 2) As Double
    Dim axisDir(0 To 2) As Double
    Dim angle As Double
    axisPt(0) = 10: axisPt(1) = -5: axisPt(2) = 0
    axisDir(0) = 10: axisDir(1) = 5: axisDir(2) = 0
    angle = 6.28
       
    ' 创建实体
    Dim solidObj As Acad3DSolid
    Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)
    ZoomAll
End Sub
这又是这么回事?

按照你给的代码修改的

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2010-8-1 22:58:00 | 显示全部楼层

求解答~~~~~~~~~~~~~~~~~~!!~!~!~!~!~!~!~!

 楼主| 发表于 2010-8-6 20:03:00 | 显示全部楼层
00000000000000000000000000
 楼主| 发表于 2010-8-12 14:50:00 | 显示全部楼层

版主,管理员。。。。。。。。帮忙解决下啊~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!!

谢谢~~~~~~~~~~~~~~~~~~!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 22:38 , Processed in 0.170903 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表