找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 401|回复: 1

[求助]:vba 代码转换成vb码

[复制链接]
发表于 2004-8-30 09:33:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
请问如何将画好的直线或圆弧命名成curvers(0)、curvers(1)等?
或者将下面的的代码转换成vb码


Sub Example_AddRevolvedSolid()
    ' This example creates a solid from a region
    ' rotated around an axis.
    ' The region is created from an arc and a line.
    Dim curves(0 To 1) As AcadEntity

    ' Define the arc
    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)
   
    ' Define the line
    Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).startPoint, curves(0).endPoint)
        
    ' Create the region
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
    ZoomAll
    MsgBox "Revolve the region to create the solid.", , "AddRevolvedSolid Example"
   
    ' Define the rotation axis
    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
        
    ' Create the solid
    Dim solidObj As Acad3DSolid
    Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)
    ZoomAll
   
     ' Change the viewing direction of the viewport
    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 "Solid created.", , "AddRevolvedSolid Example"

End Sub
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-8-30 14:43:14 | 显示全部楼层
1
获取用GetEntity方法或选择集
2
set obj=getobject(,"autocad.application")
set docobj=obj.activedocument
然后用docobj代替上面的Thisdrawing
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-23 09:37 , Processed in 0.322030 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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