- 积分
- 227
- 明经币
- 个
- 注册时间
- 2009-6-2
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
<pre>我是在用VB编写的凸轮机构的参数化设计的程序,然后调用CAD出图。VB的程序运行都没有问题,也在picturebox里看到了静态的凸轮。但CAD里却没有任何的图形和线段。
不知道问题出在那里了,各位大侠给我那个主吧!
我程序是参考别人编的。
Private Sub Command5_Click()
'首先引用 acad 2008 Object Library类型库
Dim myAcadApp As AutoCAD.AcadApplication
Dim activeDoc As autocad.AcadDocument
Dim acMS As autocad.AcadModelSpace
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开
If Err Then '没有打开
Err.Clear
Set myAcadApp = CreateObject("Autocad.Application") '打开CAD
If Err Then
MsgBox ("不能运行AUTOCAD,请检查")
Unload Me
Exit Sub
End If
End If
myAcadApp.WindowState = autocad.acMin
'1.创建样条曲线
Dim curves As autocad.AcadSpline
Dim fitPoints(0 To 360 * 3) As Variant
Dim startTangent(0 To 2) As Double
Dim endTangent(0 To 2) As Double
Dim noOfpoints As Single
For i = 0 To 360
fitPoints(3 * i) = X(i): fitPoints(3 * i + 1) = Y(i):fitPoints(3 * i + 2) = 0 'X(i),Y(i)是尖顶凸轮的廓线上点的坐标
Next i
startTangent(0) = 0.5: startTangent(1) = 0.5: startTangent(2) = 0
endTangent(0) = 0.5: endTangent(1) = 0.5: endTangent(2) = 0
noOfpoints = 3
Set curves = myAcadApp.ActiveDocument.ModelSpace.AddSpline(fitPoints, startTangent, endTangent)
'2.创建面域
Dim regionObj As Variant
regionObj = myAcadApp.ActiveDocument.ModelSpace.AddRegion(curves)
Dim tulun3D As autocad.Acad3DSolid
Dim height As Double
Dim taperAngle As Double
height = 100: taperAngle = 45
Set tulun3D = myAcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(regionObj(0), height, taperAngle)
End Sub </pre><pre>是不是创建样条曲线的时候出的问题啊。VB程序中,凸轮上我是每隔一度确定的一个计算点。CAD里一点图形都没有,会是fitpoints或者starttangent和endtangent之处的问题吗?</pre><pre> </pre> |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|