- 积分
- 16008
- 明经币
- 个
- 注册时间
- 2003-4-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2005-2-24 19:38:00
|
显示全部楼层
我的代码为:
Private Sub cmdDraw_Click() Dim objEllipse1 As AcadEllipse Dim objEllipse2 As AcadEllipse Dim linea, lineb, linec, lined, linee, linef, lineg As AcadLine Dim ptCen(0 To 2) As Double, radRatio1, radRatio2 As Double Dim pt1(0 To 2) As Double, pt2(0 To 2) As Double, sca As Double Dim pt3(0 To 2) As Double, pt4(0 To 2) As Double Dim pt5(0 To 2) As Double, pt6(0 To 2) As Double Dim pt7(0 To 2) As Double, pt8(0 To 2) As Double Dim pt9(0 To 2) As Double, pt10(0 To 2) As Double Dim pt11(0 To 2) As Double, pt12(0 To 2) As Double Dim ptmajAxis1(0 To 2) As Double, ptmajAxis2(0 To 2) As Double Dim CenPt As Variant, OldCmdEcho As Variant OldCmdEcho = ThisDrawing.GetVariable("cmdecho") Dim objLayer As AcadLayer OldLayer = ThisDrawing.GetVariable("clayer") Set objLayer = ThisDrawing.Layers.Add("1轮廓实线层") ThisDrawing.ActiveLayer = objLayer frmHD.Hide
sca = cboSc.Text deg = (cboDeg.Text * 3.1415926) / 180 CenPt = ThisDrawing.Utility.GetPoint(, "输入中心点:")
pt1(0) = CenPt(0) - D / 2 * sca pt1(1) = CenPt(1) pt1(2) = CenPt(2)
pt2(0) = CenPt(0) - D / 2 * sca pt2(1) = CenPt(1) + H pt2(2) = CenPt(2)
pt3(0) = CenPt(0) + D / 2 * sca pt3(1) = CenPt(1) + H pt3(2) = CenPt(2)
pt4(0) = CenPt(0) + D / 2 * sca pt4(1) = CenPt(1) pt4(2) = CenPt(2)
pt5(0) = CenPt(0) - D / 2 * sca - t * sca pt5(1) = CenPt(1) pt5(2) = CenPt(2)
pt6(0) = CenPt(0) - D / 2 * sca - t * sca pt6(1) = CenPt(1) + H pt6(2) = CenPt(2)
pt7(0) = CenPt(0) + D / 2 * sca + t * sca pt7(1) = CenPt(1) + H pt7(2) = CenPt(2)
pt8(0) = CenPt(0) + D / 2 * sca + t * sca pt8(1) = CenPt(1) pt8(2) = CenPt(2)
pt9(0) = CenPt(0) pt9(1) = CenPt(1) - 5 * sca pt9(2) = CenPt(2)
pt10(0) = CenPt(0) pt10(1) = CenPt(1) + (H + h1 + t + 5) * sca pt10(2) = CenPt(2)
pt11(0) = CenPt(0) - D / 2 * sca - t * sca - 5 * sca pt11(1) = CenPt(1) + H pt11(2) = CenPt(2)
pt12(0) = CenPt(0) + D / 2 * sca + t * sca + 5 * sca pt12(1) = CenPt(1) + H pt12(2) = CenPt(2)
ptmajAxis1(0) = D / 2 * sca ptmajAxis1(1) = 0 ptmajAxis1(2) = 0 radRatio1 = 0.5
ptmajAxis2(0) = (D / 2 + t) * sca ptmajAxis2(1) = 0 ptmajAxis2(2) = 0 radRatio2 = (h1 + t) / (D / 2 + t)
ptCen(0) = CenPt(0) ptCen(1) = CenPt(1) + H * sca ptCen(2) = CenPt(2) Dim FT As String FT = "Head" Set blockObj = ThisDrawing.Blocks.Add(CenPt, FT)
Set objEllipse1 = blockObj.AddEllipse(ptCen, ptmajAxis1, radRatio1) objEllipse1.StartAngle = 0 objEllipse1.EndAngle = 3.1415926
Set objEllipse2 = blockObj.AddEllipse(ptCen, ptmajAxis2, radRatio2) objEllipse2.StartAngle = 0 objEllipse2.EndAngle = 3.1415926
Set linea = blockObj.AddLine(pt1, pt2) Set lineb = blockObj.AddLine(pt3, pt4) Set linec = blockObj.AddLine(pt5, pt6) Set lined = blockObj.AddLine(pt7, pt8) Set linee = blockObj.AddLine(pt5, pt8)
Set objLayer = ThisDrawing.Layers.Add("3中心线层") ThisDrawing.ActiveLayer = objLayer Set linef = blockObj.AddLine(pt9, pt10) Set lineg = blockObj.AddLine(pt11, pt12)
Set objLayer = ThisDrawing.Layers.Add("0") ThisDrawing.ActiveLayer = objLayer
Dim blockRefObj As AcadBlockReference Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(CenPt, FT, sca, sca, sca, deg)
ThisDrawing.Regen acActiveViewport
Set blockRefObj = Nothing Set blockObj = Nothing Unload Me ThisDrawing.SetVariable "cmdecho", OldCmdEcho ThisDrawing.SetVariable "clayer", OldLayer End Sub
第一次使用VB,请不要见笑,谢谢! |
|