- 积分
- 470
- 明经币
- 个
- 注册时间
- 2002-9-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2002-10-17 12:59:00
|
显示全部楼层
我担心你下载不到文件,就吧代码写了出来
包括的控件:
form:caption "OFFSET" name "MAIN"
textbox:text "" name text1
bottoncommand: ok
bottoncommand :cancel
label: caption "偏移量" name "label1"
代码开始:
Option Explicit
Dim acadapp As Object
Dim preference As Object
Dim acaddoc As Object
Dim paspace As Object
Dim mospace As Object
Dim offsetl As Double
Dim object As Object
Dim cishu As Integer
Dim PickedPoint As Variant
Dim TransMatrix As Variant
Dim ContextData As Variant
Dim HasContextData As String
Private Sub CANCEL_Click()
Unload Me
End Sub
Private Sub Form_Load()
'初始化CAD
On Error Resume Next
Set acadapp = GetObject(, "autocad.application")
If Err Then
Err.Clear
Set acadapp = CreateObject("autocad.application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
acadapp.Visible = True
Set preference = acadapp.Preferences
Set acaddoc = acadapp.ActiveDocument
Set mospace = acaddoc.ModelSpace
Set paspace = acaddoc.PaperSpace
End Sub
Private Sub OK_Click()
offsetl = Text1.Text
'选择偏移对象
On Error GoTo NOT_ENTITY
TRYAGAIN:
If (cishu = 3) Then
GoTo tuich
End If
'在这里设置你要的图层
acaddoc.Utility.GetSubEntity object, PickedPoint, TransMatrix, ContextData, "选择需要进行偏移的对象:"
'在这里设置你要的图层
object.Offset (offsetl)
object.Offset (-offsetl)
NOT_ENTITY:
cishu = cishu + 1
Resume TRYAGAIN
'用户3次没有选择到则自动退出程序
tuich:
If (cishu = 3) Then
Unload Me
Else
main.Show
End If
End Sub
代码结束! |
|