注册

减振器屋

查看: 4759|回复: 1
打印 上一主题 下一主题

基于VB&AutoCAD的螺旋面的绘制(原代码)

[复制链接]
跳转到指定楼层
1#
发表于 2009-3-20 12:36:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Private Sub Command1_Click()

Dim theta, r1, r2, h1, h0, l

l = Val(Me.Text1)

theta = Val(Me.Text2) / 180 * 3.1415

r1 = Val(Me.Text3)

r2 = Val(Me.Text4)

ActiveDocument.SendCommand "_shademode" + vbCr + "_G" + vbCr

Dim center_point(0 To 2) As Double

center_point(0) = 0: center_point(1) = 0: center_point(2) = 0

Dim lines(0 To 0) As AcadCircle

Set lines(0) = ActiveDocument.ModelSpace.AddCircle(center_point, r2)

Dim region As Variant

region = ActiveDocument.ModelSpace.AddRegion(lines)

Dim base As Acad3DSolid

h = 5 * l

Set base = ActiveDocument.ModelSpace.AddExtrudedSolid(region(0), h, 0)

base.Color = acBlue

Dim ptcontrol() As Double

Dim ptcontrol1() As Double

Dim k As Integer

Dim liness(0 To 700) As AcadLine

k = 700

ReDim ptcontrol(3 * k + 2) As Double

ReDim ptcontrol1(3 * k + 2) As Double

Dim stpt(0 To 2) As Double

Dim etpt(0 To 2) As Double

For i = 0 To k Step 1

ptcontrol(3 * i) = r2 * Cos(2 * 3.1415926 * i / 180)

ptcontrol(3 * i + 1) = r2 * Sin(2 * 3.1415926 * i / 180)

ptcontrol(3 * i + 2) = l / (2 * 3.1415) * (2 * 3.1415926 * i / 180) + r2 * Tan(theta) - 5

stpt(0) = ptcontrol(3 * i): stpt(1) = ptcontrol(3 * i + 1): stpt(2) = ptcontrol(3 * i + 2)

ptcontrol1(3 * i) = r1 * Cos(2 * 3.1415926 * i / 180)

ptcontrol1(3 * i + 1) = r1 * Sin(2 * 3.1415926 * i / 180)

ptcontrol1(3 * i + 2) = l / (2 * 3.1415) * (2 * 3.1415926 * i / 180) + r1 * Tan(theta) - 5

etpt(0) = ptcontrol1(3 * i): etpt(1) = ptcontrol1(3 * i + 1): etpt(2) = ptcontrol1(3 * i + 2)

Set liness(i) = ActiveDocument.ModelSpace.AddLine(stpt, etpt)

liness(i).Color = acRed

Next i

Dim luo As Acad3DPolyline

Set luo = ActiveDocument.ModelSpace.Add3DPoly(ptcontrol1)

luo.Color = acGreen

Dim wailuo As Acad3DPolyline

Set wailuo = ActiveDocument.ModelSpace.Add3DPoly(ptcontrol)

wailuo.Color = acYellow

End Sub

Private Sub Command2_Click()

End

End Sub
2#
发表于 2019-6-26 13:26:00 | 只看该作者
这是什么东东
游客
回复
您需要登录后才可以回帖 登录 | 注册

Archiver|手机版|小黑屋|减振器屋 ( 皖ICP备09000246号-1 )

GMT+8, 2024-11-22 05:56 , Processed in 0.041003 second(s), 18 queries .

Powered by JZQ5.CN X3.2

© 2001-2022 减振器屋

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