- UID
- 53948
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-5-30
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我想用vb实现extrim的功能,现在已经把程序编出来了
但是就是不能修剪,在向cad传命令的时候,trim的"f"
模式好像不管用的,烦请各位大侠帮忙看看
这样的思路可行吗?
Sub sdstr()
On Error GoTo Err_Control
Dim StrFilterType As Variant, StrFilterData As Variant
Dim Gpcode(1) As Integer, Datavalue(1) As Variant
Dim StrSset As AcadSelectionSet
Dim StrVbPnt As Variant
Dim StrLspPnt(2) As Double
Dim StrlspTmpPnt1(2), StrlspTmpPnt2(2) As Double
Dim StrVbLinePnt(1) As Variant
Dim StrLspLinePnt1(2), StrLspLinePnt2(2) As Double
Dim i, j, k As Double
Dim l, m, n As Integer
Gpcode(0) = 0
Datavalue(0) = "line"
Gpcode(1) = 0
Datavalue(1) = "line"
StrFilterType = Gpcode
StrFilterData = Datavalue
'初始化选择集
If ThisDrawing.SelectionSets.Count <> 1 Then
For g = 0 To ThisDrawing.SelectionSets.Count - 1
ThisDrawing.SelectionSets.Item(g).Clear
ThisDrawing.SelectionSets.Item(g).Delete
Next
End If
Set StrSset = ThisDrawing.SelectionSets.Add("StrSset")
StrSset.Highlight True
StrSset.Update
' 提示用户选择对象并将它们添加到选择集中。
ThisDrawing.Utility.Prompt "请选择剪切边界:"
StrSset.SelectOnScreen StrFilterType, StrFilterData
StrVbPnt = ThisDrawing.Utility.GetPoint(, "指定要修剪的一侧:")
StrLspPnt(0) = StrVbPnt(0) '取得修剪边的坐标
StrLspPnt(1) = StrVbPnt(1)
StrLspPnt(2) = StrVbPnt(2)
For Each Entry In StrSset
StrVbLinePnt(0) = Entry.StartPoint '获得直线的坐标
StrVbLinePnt(1) = Entry.EndPoint
StrLspLinePnt1(0) = StrVbLinePnt(0)(0) '对直线坐标进行赋值
StrLspLinePnt1(1) = StrVbLinePnt(0)(1)
StrLspLinePnt2(0) = StrVbLinePnt(1)(0)
StrLspLinePnt2(1) = StrVbLinePnt(1)(1)
'得到第一个辅助点
StrlspTmpPnt1(0) = StrLspLinePnt1(0) + 10 * Cos(Atn((StrLspLinePnt1(1) - StrLspPnt(1)) / (StrLspLinePnt1(0) - StrLspPnt(0))))
StrlspTmpPnt1(1) = StrLspLinePnt1(1) + 10 * Sin(Atn((StrLspLinePnt1(1) - StrLspPnt(1)) / (StrLspLinePnt1(0) - StrLspPnt(0))))
StrlspTmpPnt1(2) = 0
'得到第二个辅助点
StrlspTmpPnt2(0) = StrLspLinePnt2(0) - 10 * Cos(Atn((StrLspLinePnt2(1) + StrLspPnt(1)) / (StrLspLinePnt2(0) - StrLspPnt(0))))
StrlspTmpPnt2(1) = StrLspLinePnt2(1) - 10 * Sin(Atn((StrLspLinePnt2(1) + StrLspPnt(1)) / (StrLspLinePnt2(0) - StrLspPnt(0))))
StrlspTmpPnt2(2) = 0
ThisDrawing.SendCommand "_zoom" & vbCr & "extents" & vbCr
Call ThisDrawing.SendCommand("_trim" & vbCr & "(handent " & Chr(34) & Entry.Handle & Chr(34) & ")" & vbCr & "f" & vbCr & StrlspTmpPnt1(0) & "," & StrlspTmpPnt1(1) _
& vbCr & StrlspTmpPnt2(0) & "," & StrlspTmpPnt2(1) & " " & vbCr & " " & vbCr)
'检查临时选择线条的位置
'ThisDrawing.SendCommand ("_line" & vbCr & StrlspTmpPnt1(0) & "," & StrlspTmpPnt1(1) & vbCr & StrlspTmpPnt2(0) & "," & StrlspTmpPnt2(1) & vbCr)
Next Entry
Err_Control:
StrSset.Delete
End Sub |
|