明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 705|回复: 2

[VBA群] 2013-05-03 明经AutoCAD.VBA编程(45054712) 群聊记录:欢迎 凡心(51734049) 加入明经AutoCAD.VBA编程,请先将你

 关闭 [复制链接]
发表于 2013-5-3 18:17 | 显示全部楼层 |阅读模式
cad 2d 3d 18:17:21
欢迎 凡心(51734049) 加入明经AutoCAD.VBA编程,请先将你在群中的昵称修改为“[论坛用户名]凡心”格式,如果你未加入明经CAD社区,请先到http://bbs.mjtd.com注册用户。
 楼主| 发表于 2013-5-3 19:59 | 显示全部楼层
zcdchh心语 19:59:38
Dim d1 As Integer
Dim d2 As Integer
Dim h As Integer
Dim c As Single
Dim c1 As Single
Dim c2 As Single
Form1.Hide                                  '隐藏界面
d1 = Text1.Text                             '对参数赋值
d2 = Text2.Text
h = Text3.Text
c = Text4.Text
c1 = Text5.Text
c2 = Text6.Text
strfilename = CurrentDir + "\" + "衬套.SLDPRT"
Set swApp = CreateObject("SldWorks.Application")        '创建SldWorks对象
swApp.Visible = True                       '设置显示SolidWorks程序界面
Set art = swApp.opendoc6(strfilename, 1, 0, "", longstatus, longstatus)  '打开作为模板的零件
Set art = swApp.ActiveDoc                 '激活文件
strfilename = "衬套.SLDPRT"
longstatus = art.Parameter("d1@草图1@strfilename").SetSystemValue3(d1 / 1000, 1, "默认")
longstatus = art.Parameter("d2@草图1@strfilename").SetSystemValue3(d2 / 1000, 1, "默认")
longstatus = art.Parameter("d1@拉伸1@strfilename").SetSystemValue3(h / 1000, 1, "默认")
longstatus = art.Parameter("d1@倒角1@strfilename").SetSystemValue3(c / 1000, 1, "默认")
longstatus = art.Parameter("d1@倒角2@strfilename").SetSystemValue3(c1 / 1000, 1, "默认")
longstatus = art.Parameter("d1@倒角3@strfilename").SetSystemValue3(c2 / 1000, 1, "默认")          '将参数值赋予零件,生成所需模型
Select Case d2
Case 11 To 18
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(0.8 / 1000, 1, "默认")
Case 19 To 30
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(1 / 1000, 1, "默认")
Case 31 To 50
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(1.6 / 1000, 1, "默认")
Case 51 To 80
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(2 / 1000, 1, "默认")
Case 81 To 120
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(2.5 / 1000, 1, "默认")
Case 121 To 180
longstatus = art.Parameter("d1@倒角4@strfilename").SetSystemValue3(3 / 1000, 1, "默认")
End Select                                '根据未注倒角规定确定倒角值
boolstatus = art.EditRebuild3()          '重建模型
Part.ShowNamedView2 "*等轴测", 7          '等轴测显示模型
Part.ViewZoomtofit2                       '自动缩放整屏显示全图
Form1.Show                                '显示界面
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 16:03 , Processed in 5.307728 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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