为什么这两个点会用不同的坐标转换矩阵?
本帖最后由 ywlm 于 2011-8-16 21:05 编辑注释中第一个矩阵和第二个矩阵必须选择代码中的转换矩阵才行,如果两个都选ed.CurrentUserCoordinateSystem或都选Matrix3d.Identity就不行,这是为什么?
''' <summary>
''' 由起点和中点绘制直线
''' </summary>
''' <remarks></remarks>
Public Class DrawJig_Line
Inherits DrawJig
Private ent As Line
Private sPt As Point3d
Private ePt As Point3d
Private funCount As Integer = 1
<CommandMethod("ll")> _
Sub DrawLine()
Dim optFirstPoint As New PromptPointOptions(vbCrLf & "指定中点 或<指定端点>:")
With optFirstPoint
.AllowNone = True
End With
Dim resFirstPoint As PromptPointResult = ed.GetPoint(optFirstPoint)
If resFirstPoint.Status = PromptStatus.None Then
optFirstPoint.Message = "指定端点:"
resFirstPoint = ed.GetPoint(optFirstPoint)
funCount = 2
End If
If resFirstPoint.Status <> PromptStatus.OK Then Return
sPt = resFirstPoint.Value
sPt = sPt.TransformBy(ed.CurrentUserCoordinateSystem)'===第一个矩阵===
ePt = sPt
ent = New Line(sPt, ePt)
Dim resJigPoint As PromptResult = ed.Drag(Me)
If resJigPoint.Status = PromptStatus.OK Then
AppendEntity(ent)
End If
ent.Dispose()
funCount = 1
End Sub
Protected Overrides Function Sampler(ByVal prompts As Autodesk.AutoCAD.EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus
Dim Message As String = IIf(funCount = 1, "指定端点:", "指定中点:")
Dim optJigPoint As New JigPromptPointOptions(vbCrLf & Message)
With optJigPoint
.BasePoint = sPt
.UseBasePoint = True
.UserInputControls = UserInputControls.Accept3dCoordinates
End With
Dim resJigPoint As PromptPointResult = prompts.AcquirePoint(optJigPoint)
If resJigPoint.Status <> PromptStatus.OK Then Return SamplerStatus.Cancel
ePt = resJigPoint.Value
ePt = ePt.TransformBy(Matrix3d.Identity)'===第二个矩阵===
If sPt = ePt Then Return SamplerStatus.NoChange
If funCount = 1 Then
ent.EndPoint = ePt
ent.StartPoint = sPt + (sPt - ePt)
Else
ent.StartPoint = sPt
ent.EndPoint = sPt + 2 * (ePt - sPt)
End If
Return SamplerStatus.OK
End Function
Protected Overrides Function WorldDraw(ByVal draw As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean
draw.Geometry.Draw(ent)
Return True
End Function
End Class
原来第二个矩阵处的这行代码可以取消,没意义的。
是否可以这样理解:ed.GetPoint获得的是UCS坐标,而prompts.AcquirePoint获得的是WCS坐标?
页:
[1]