- 积分
- 299
- 明经币
- 个
- 注册时间
- 2003-7-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
是从“实用函数”里学到的方法,做了一些修改:
Public Sub Trim(ByVal cutLine1 As AcadLine, ByVal cutLine2 As AcadLine, _
ByVal entSP As AcadSpline, ByVal optCode As String)
'cutLine1 cutLine2是_trim的两个边界线,endSP是要剪的样条曲线。
Dim det1, det2 As String
det1 = axEnt2lspEnt(cutLine1)
det2 = axEnt2lspEnt(cutLine2)
Dim det3, det4 As String
det3 = GetDoubleEntTable(entSP, entSP.GetControlPoint(0))
det4 = GetDoubleEntTable(entSP, entSP.GetControlPoint(entSP.NumberOfControlPoints - 1))
If optCode = "first" Then
ThisDrawing.SendCommand "_trim" & vbCr & det2 & vbCr & _
vbCr & det4 & vbCr & vbCr
GoTo rtn
End If
If optCode = "last" Then
ThisDrawing.SendCommand "_trim" & vbCr & det1 & vbCr & _
vbCr & det3 & vbCr & vbCr
GoTo rtn
End If
ThisDrawing.SendCommand "_trim" & vbCr & det1 & vbCr & det2 & _
vbCr & vbCr & det3 & vbCr & det4 & vbCr & vbCr
rtn:
End Sub
'转换双元表的函数
Private Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String
Dim entHandle As String
entHandle = entObj.Handle
GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _
")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"
End Function
'转换点的函数
Private Function axPoint2lspPoint(Pnt As Variant) As String
axPoint2lspPoint = Pnt(0) & "," & Pnt(1) & "," & Pnt(2)
End Function
'转换图元函数
Private Function axEnt2lspEnt(entObj As AcadEntity) As String
Dim entHandle As String
entHandle = entObj.Handle
axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function
作用主要是把样条曲线其中两个拟合点之间的一段剪出来,但在弯比较急的地方经常剪不断,造成出错。请问怎么办? |
|