明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1698|回复: 3

请各位大高手大哥帮我看下这个程序,解决下问题 谢谢

[复制链接]
发表于 2005-6-1 00:04:00 | 显示全部楼层 |阅读模式
我是初学者,请教哪位大虾可以把它改一下,因为我这个程序只有画5边形才能放,有没有可以弄个循环语句然后随便画几边形都可以进行缩放.
Sub Line2() Dim VarRet As Variant
Dim NewLine1 As Object
Dim NewLine2 As Object
Dim NewLine3 As Object
Dim PT1(0 To 2) As Double
Dim PT2(0 To 2) As Double
Dim PT3(0 To 2) As Double
Dim PT4(0 To 2) As Double
Dim PT5(0 To 2) As Double Dim points(0 To 9) As Double
Dim plineObj As AcadLWPolyline
Dim i As Variant
Dim j As Variant
Dim s As Variant
Dim t As Variant
Dim k As Variant
Dim m As Variant
Dim n As Variant
k = ThisDrawing.Utility.GetInteger("请输入边数:")
i = ThisDrawing.Utility.GetInteger("请输入向内放样个数:")
s = ThisDrawing.Utility.GetInteger("请输入向外放样个数:")
VarRet = Utility.GetPoint(, "Point1: ")
PT1(0) = VarRet(0)
PT1(1) = VarRet(1) VarRet = Utility.GetPoint(PT1, "Point2: ")
PT2(0) = VarRet(0)
PT2(1) = VarRet(1) VarRet = Utility.GetPoint(PT1, "Point3: ")
PT3(0) = VarRet(0)
PT3(1) = VarRet(1) VarRet = Utility.GetPoint(PT1, "Point4: ")
PT4(0) = VarRet(0)
PT4(1) = VarRet(1) VarRet = Utility.GetPoint(PT1, "Point5: ")
PT5(0) = VarRet(0)
PT5(1) = VarRet(1) points(0) = PT1(0)
points(1) = PT1(1)
points(2) = PT2(0)
points(3) = PT2(1)
points(4) = PT3(0)
points(5) = PT3(1)
points(6) = PT4(0)
points(7) = PT4(1)
points(8) = PT5(0)
points(9) = PT5(1) Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
plineObj.Closed = True
Set PlineCopy = plineObj.Copy
PlineCopy.color = acRed
ZoomAll Do
m = ThisDrawing.Utility.GetInteger("请输入向内偏移量:")
If m <= 0 Then
MsgBox "请输入正值"
Else
Exit Do
End If
Loop Do
n = ThisDrawing.Utility.GetInteger("请输入向外偏移量(-):")
If n >= 0 Then
MsgBox "请输入负值"
Else
Exit Do
End If
Loop Dim offsetObj As Variant
For j = 1 To i
offsetObj = plineObj.Offset(m * j) Next j
ZoomAll
For t = 1 To s
offsetObj = plineObj.Offset(n * t) Next t
ZoomAll End Sub
发表于 2005-6-1 16:06:00 | 显示全部楼层
'可以输入任意边数:Sub Line2()Dim VarRet As Variant
Dim NewLine1 As Object
Dim NewLine2 As Object
Dim NewLine3 As Object
Dim PT1(0 To 2) As Double
Dim PT2(0 To 2) As Double
Dim PT3(0 To 2) As Double
Dim PT4(0 To 2) As Double
Dim PT5(0 To 2) As DoubleDim points(0 To 9) As Double
Dim plineObj As AcadLWPolyline
Dim i As Variant
Dim j As Variant
Dim s As Variant
Dim t As Variant
  1. Dim k As Integer
Dim m As Variant
Dim n As Variant
  1. Dim a
  2. Dim Var As Variant
  3. k = ThisDrawing.Utility.GetInteger("请输入边数:")
  4. ReDim Var(2 * k - 1) As Double
  5.   
  6. i = ThisDrawing.Utility.GetInteger("请输入向内放样个数:")
  7. s = ThisDrawing.Utility.GetInteger("请输入向外放样个数:")
  8. For a = 0 To k - 1
  9. VarRet = Utility.GetPoint(, "Point" & Str(a) & ": ")
  10. Var(2 * a) = VarRet(0)
  11. Var(2 * a + 1) = VarRet(1)
  12. NextSet plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(Var)
plineObj.Closed = True
Set PlineCopy = plineObj.Copy
PlineCopy.color = acRed
ZoomAllDo
m = ThisDrawing.Utility.GetInteger("请输入向内偏移量:")
If m <= 0 Then
MsgBox "请输入正值"
Else
Exit Do
End If
LoopDo
n = ThisDrawing.Utility.GetInteger("请输入向外偏移量(-):")
If n >= 0 Then
MsgBox "请输入负值"
Else
Exit Do
End If
LoopDim offsetObj As Variant
For j = 1 To i
offsetObj = plineObj.Offset(m * j)Next j
ZoomAll
For t = 1 To s
offsetObj = plineObj.Offset(n * t)Next t
ZoomAllEnd Sub
发表于 2011-12-10 23:37:27 | 显示全部楼层
收下,谢谢分享
发表于 2011-12-10 23:39:44 | 显示全部楼层
很多都看不懂啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 18:36 , Processed in 0.161380 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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