乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 52|回复: 1

好版主,我在开发autocad的时候有出现小问题了!帮帮我了!

[复制链接]

6

主题

13

帖子

1

银币

初来乍到

Rank: 1

铜币
37
发表于 2003-4-28 14:41:00 | 显示全部楼层 |阅读模式
好心的版主,您好!又来麻烦您了,我真不好意思!   
具体情况如下:我已经将visualbasic与2000通讯上了,为了画一个刀具的图,可画出来只有半边,怎么都不能使右边的这段2维多义线镜象到左边去(autocad画完右边的多义线就停了下来了)我查了好多质料,发现语法没有问题。希望您能告诉我问题的所在,在这里先谢谢您了!还有就是我这段程序如何在2维平面中创建一个面域(左右多义线合并为一个封闭的线框)啊?
    程序:
Private Sub Command1_Click()
On Error Resume Next
Dim wg As Double
wg = 10
Dim wd As Double
wd = 10
Dim wm As Double
wm = 10
cad.Document.Add
'转换视点
Dim newdirection(0 To 2) As Double
newdirection(0) = 1: newdirection(1) = 0.5: newdirection(2) = 0.5
cad.ActiveDocument.ActiveViewport.Direction = newdirection
cad.ActiveDocument.ActiveViewport = cad.ActiveDocument.ActiveViewport
cad.ActiveDocument.Layers(0).Color = acRed
cad.ActiveDocument.SendCommand "_shademode" + vbCr + "_g" + vbCr
'拉伸cad
'由于ZA型蜗杆轴向压力角为20度,得蜗杆齿高
Dim thdg As Double
Dim th1 As Double
Dim th2 As Double
thdg = 20 'thdg=(wd-wg)/2
th1 = 2 'th1=wm*3.14159/4-(wf-wd)*tan(20)/2
th2 = 5 'th2=wm*3.14159/2+.72794*wm
Dim curves(1) As AcadLWPolyline
Dim points(0 To 9) As Double
points(0) = wg / 2: points(1) = 0 '第1点
points(2) = wg / 2: points(3) = th1 '第2点
points(4) = wd / 2: points(5) = th2 '第3点
points(6) = wd / 2 + wm: points(7) = th2 '第4点
points(8) = wd / 2 + wm: points(9) = 0 '第5点
'创建刀具右部线段
Set curves(0) = cad.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)
curves(0).SetBulge 1, -0.3
Dim point1(0 To 1) As Double
Dim point2(0 To 2) As Double
point1(1) = -2: point1(1) = 0: point1(2) = 0
point2(1) = 2: point2(1) = 0: point2(2) = 0
'镜像刀具右部线段,得到左部线段
Set curves(1) = curves(0).Mirror(point1, point2)
Dim 刀具 As Variant
刀具 = cad.ActiveDocument.ModelSpace.AddRegion(curves)
'创建刀具面域(?不会了)
'拉伸刀具(面域)得到三维刀具实体
Dim height As Double
Dim angle As Double
height = 3
angle = 0 '弧度
'创建面域拉伸实体
Dim solidobj As Acad3DSolid
Set solidobj = cad.ActiveDocument.ModelSpace.AddExtrudedSolid(刀具, height, angle)
               
ZoomAll
End Sub
回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 2003-4-28 20:12:00 | 显示全部楼层
1.以下语句:
Dim point1(0 To 1) As Double
Dim point2(0 To 2) As Double
point1(1) = -2: point1(1) = 0: point1(2) = 0
point2(1) = 2: point2(1) = 0: point2(2) = 0
中有两个问题:
point1(0 to 1)定义的数组只有两个元素,怎能容纳三个元素?所以要改为2
point1(1)=-2这里就错了,重复定义point1(1)以及point2(1),而point1(0)和point2(0)却没有定义。这样就造成了点重复的问题了。
2.在以下语句中:
Set solidobj = cad.ActiveDocument.ModelSpace.AddExtrudedSolid(刀具, height, angle)
注意,“刀具”变体数组保存着所生成的面域的数组,这里刀具有可能不只包含一个面域,具体要看给定曲线一共能生成多少个面域,所以该值为不定,所以在引用刀具值来生成实体时应用使用“刀具(0)”来引用其中的第一个面域,而不是引用刀具变体。
改完后,程序应该可以正常运行。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 14:05 , Processed in 0.564891 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表