'大括号
Public Class 大括号
' 从DrawJig类继承.
Inherits DrawJig
' 拖拽的对象.
Dim Ent As Polyline
' 拖拽指向的点.
Private StartPt, EndPt As Point3d
'大括号
<CommandMethod("DKH")> _
Public Sub DKH()
'On Error Resume Next
GetPoint(StartPt)
Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
Dim acEditor As Editor = Application.DocumentManager.MdiActiveDocument.Editor
' 开始拖拽.
Dim resJig As PromptResult = acEditor.Drag(Me)
If resJig.Status = PromptStatus.OK Then
'确定后添加对象
AddEnt(Ent)
End If
End Sub
' Sampler函数用于检测用户的输入.
Protected Overrides Function Sampler(ByVal Prompts As JigPrompts) As SamplerStatus
' 定义一个点拖动交互类.
Dim optJigPoint As New JigPromptPointOptions(vbCrLf & "请指定插入点:")
' 设置拖拽光标类型.
optJigPoint.Cursor = CursorType.RubberBand
' 设置拖动光标基点.
optJigPoint.BasePoint = StartPt
optJigPoint.UseBasePoint = True
' 用AcquirePoint函数得到用户输入的点.
Dim resJigPoint1 As PromptPointResult = Prompts.AcquirePoint(optJigPoint)
Dim curPt As Point3d = resJigPoint1.Value
If curPt <> EndPt Then
'折断线绘制*******************************************************
'
' ∧
' ------------------- / \ ----------------------
' / \
' P3
'
' P1 P2 P4 P5
' P0 P6
'
Dim L As Double = StartPt.DistanceTo(curPt)
Dim A As Double = P2P_AngleByVBA(StartPt.ToArray, curPt.ToArray)
Dim Pc As Point3d = New Point3d((StartPt.X + curPt.X) / 2, (StartPt.Y + curPt.Y) / 2, 0)
Dim Pi As Double = System.Math.PI
Ent = New Polyline
Dim Temp As Point3d = StartPt
Ent.AddVertexAt(0, P32(Temp), 0, 0, 0) 'p0
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi - 45)
Ent.AddVertexAt(1, P32(Temp), 0, 0, 0) 'p1
Temp = GetPointAR(Temp, 0.359 * L, A * 180 / Pi)
Ent.AddVertexAt(2, P32(Temp), 0, 0, 0) 'p2
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi - 45)
Ent.AddVertexAt(3, P32(Temp), 0, 0, 0) 'p3
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi + 45)
Ent.AddVertexAt(4, P32(Temp), 0, 0, 0) 'p4
Temp = GetPointAR(Temp, 0.359 * L, A * 180 / Pi)
Ent.AddVertexAt(5, P32(Temp), 0, 0, 0) 'p5
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi + 45)
Ent.AddVertexAt(6, P32(Temp), 0, 0, 0) 'p6
Ent.Highlight()
' 保存当前点.
EndPt = curPt
Return SamplerStatus.OK
Else
Return SamplerStatus.NoChange
End If
End Function
' WorldDraw函数用于刷新屏幕上显示的图形.
Protected Overrides Function WorldDraw(ByVal Draw As WorldDraw) As Boolean
' 刷新画面.
Draw.Geometry.Draw(Ent)
Return True
End Function
End Class
Public Class 大括号
' 从DrawJig类继承.
Inherits DrawJig
' 拖拽的对象.
Dim Ent As Polyline
' 拖拽指向的点.
Private StartPt, EndPt As Point3d
'大括号
<CommandMethod("DKH")> _
Public Sub DKH()
'On Error Resume Next
GetPoint(StartPt)
Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
Dim acEditor As Editor = Application.DocumentManager.MdiActiveDocument.Editor
' 开始拖拽.
Dim resJig As PromptResult = acEditor.Drag(Me)
If resJig.Status = PromptStatus.OK Then
'确定后添加对象
AddEnt(Ent)
End If
End Sub
' Sampler函数用于检测用户的输入.
Protected Overrides Function Sampler(ByVal Prompts As JigPrompts) As SamplerStatus
' 定义一个点拖动交互类.
Dim optJigPoint As New JigPromptPointOptions(vbCrLf & "请指定插入点:")
' 设置拖拽光标类型.
optJigPoint.Cursor = CursorType.RubberBand
' 设置拖动光标基点.
optJigPoint.BasePoint = StartPt
optJigPoint.UseBasePoint = True
' 用AcquirePoint函数得到用户输入的点.
Dim resJigPoint1 As PromptPointResult = Prompts.AcquirePoint(optJigPoint)
Dim curPt As Point3d = resJigPoint1.Value
If curPt <> EndPt Then
'折断线绘制*******************************************************
'
' ∧
' ------------------- / \ ----------------------
' / \
' P3
'
' P1 P2 P4 P5
' P0 P6
'
Dim L As Double = StartPt.DistanceTo(curPt)
Dim A As Double = P2P_AngleByVBA(StartPt.ToArray, curPt.ToArray)
Dim Pc As Point3d = New Point3d((StartPt.X + curPt.X) / 2, (StartPt.Y + curPt.Y) / 2, 0)
Dim Pi As Double = System.Math.PI
Ent = New Polyline
Dim Temp As Point3d = StartPt
Ent.AddVertexAt(0, P32(Temp), 0, 0, 0) 'p0
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi - 45)
Ent.AddVertexAt(1, P32(Temp), 0, 0, 0) 'p1
Temp = GetPointAR(Temp, 0.359 * L, A * 180 / Pi)
Ent.AddVertexAt(2, P32(Temp), 0, 0, 0) 'p2
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi - 45)
Ent.AddVertexAt(3, P32(Temp), 0, 0, 0) 'p3
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi + 45)
Ent.AddVertexAt(4, P32(Temp), 0, 0, 0) 'p4
Temp = GetPointAR(Temp, 0.359 * L, A * 180 / Pi)
Ent.AddVertexAt(5, P32(Temp), 0, 0, 0) 'p5
Temp = GetPointAR(Temp, L / 10, A * 180 / Pi + 45)
Ent.AddVertexAt(6, P32(Temp), 0, 0, 0) 'p6
Ent.Highlight()
' 保存当前点.
EndPt = curPt
Return SamplerStatus.OK
Else
Return SamplerStatus.NoChange
End If
End Function
' WorldDraw函数用于刷新屏幕上显示的图形.
Protected Overrides Function WorldDraw(ByVal Draw As WorldDraw) As Boolean
' 刷新画面.
Draw.Geometry.Draw(Ent)
Return True
End Function
End Class
[本日志由 tiancao1001 于 2012-03-14 02:53 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |