明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1631|回复: 1

关于vba开发的问题!(有图)

[复制链接]
发表于 2003-5-9 15:10:00 | 显示全部楼层 |阅读模式
我在编程的时候碰到了个问题:不能对中间圆柱的两个面进行拉伸(成一定的角度如图,比如是45度等)
原程序:
    On Error Resume Next
    '关闭上次运行的文件
    蜗杆cad.Document.Add '新建一文件
    Dim wd As Double
    Dim wg As Double
    Dim wf As Double
    Dim wm As Double
    Dim wk As Double '先对蜗杆各参数类型定义
   
    wm = 8 'Val(蜗杆数据输入.Combo1.Text) '模数
    wf = 80 'Val(蜗杆数据输入.Text2(0).Text) '蜗杆分度圆直径
    wk = 100 'Val(蜗杆数据输入.Text3(1).Text) '蜗杆宽度
   
    Dim newdirection(0 To 2) As Double '设置三维视点
newdirection(0) = 1: newdirection(1) = 0: newdirection(2) = 1

蜗杆cad.ActiveDocument.ActiveViewport.Direction = newdirection
蜗杆cad.ActiveDocument.ActiveViewport = 蜗杆cad.ActiveDocument.ActiveViewport
蜗杆cad.ActiveDocument.SendCommand "_shademode" + vbCr + "_g" + vbCr
   
    '蜗轮毛坏
    wd = wf + 2 * wm '蜗杆顶圆直径
    wg = wf - 2.4 * wm '蜗杆底圆直径
   
    Dim 蜗杆3d As Acad3DSolid
    Dim centerpoint(0 To 2) As Double
    centerpoint(0) = 0#: centerpoint(1) = 0#: centerpoint(2) = 0#
    'wk为蜗杆的高度,以定义
    Set 蜗杆3d = 蜗杆cad.ActiveDocument.ModelSpace.AddCylinder(centerpoint, wd / 2, wk)
    Dim b As AcadCircle
    Dim b2(3) As Acad3DSolid
    Dim height As Double
    Dim taperangle As Double
    Dim circlepoint(2) As Double
    Dim circlepoint1(2) As Double
    Dim r1 As Double
    Dim mirpt1(2), mirpt2(2) As Double
    circlepoint(0) = 0: circlepoint(1) = 0: circlepoint(2) = wk / 2
    r1 = wd / 2
    Set b = 蜗杆cad.ActiveDocument.ModelSpace.AddCircle(circlepoint, r1)
   
    '拉伸该圆,成45度角
    Dim bface As Variant
    bface = 蜗杆cad.ActiveDocument.ModelSpace.AddRegion(b)
    height = wd / 2
    taperangle = 45 * 3.14 / 360
    Set b2(0) = 蜗杆cad.ActiveDocument.ModelSpace.AddExtrudedSolid(bface, height, taperangle)
    circlepoint1(0) = 0: circlepoint1(1) = 0: circlepoint1(2) = wd + wk / 2
    Set b2(1) = 蜗杆cad.ActiveDocument.ModelSpace.AddCylinder(centerpoint1, wd / 4, wd)
   
    mirpt1(0) = 0: mirpt1(1) = 1: mirpt1(2) = 0
    mirpt2(0) = 1: mirpt2(1) = 0: mirpt2(2) = 0
    Set b2(3) = b2(0).Mirror3D(centerpoint, mirpt1, mirpt2)
    Set b2(3) = b2(1).Mirror3D(centerpoint, mirpt1, mirpt2)
    蜗杆3d.Boolean acUnion, b()
    蜗杆3d.UpdateC:\WINDOWS\Desktop

本帖子中包含更多资源

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

x
 楼主| 发表于 2003-5-12 10:15:00 | 显示全部楼层

呵呵!我已经解决这个问题了!

呵呵!不用大家费心了!我已经解决的这个问题了!是变量定义的时候出了问题!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 16:35 , Processed in 0.164065 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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