乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 31|回复: 1

为什么这两个点会用不同的坐标转换矩阵?

[复制链接]

8

主题

26

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
58
发表于 2011-8-16 21:04:00 | 显示全部楼层 |阅读模式
注释中第一个矩阵和第二个矩阵必须选择代码中的转换矩阵才行,如果两个都选ed.CurrentUserCoordinateSystem或都选Matrix3d.Identity就不行,这是为什么?
  1.     '''
  2.     ''' 由起点和中点绘制直线
  3.     '''
  4.     '''
  5.     Public Class DrawJig_Line
  6.         Inherits DrawJig
  7.         Private ent As Line
  8.         Private sPt As Point3d
  9.         Private ePt As Point3d
  10.         Private funCount As Integer = 1
  11.          _
  12.         Sub DrawLine()
  13.             Dim optFirstPoint As New PromptPointOptions(vbCrLf & "指定中点 或:")
  14.             With optFirstPoint
  15.                 .AllowNone = True
  16.             End With
  17.             Dim resFirstPoint As PromptPointResult = ed.GetPoint(optFirstPoint)
  18.             If resFirstPoint.Status = PromptStatus.None Then
  19.                 optFirstPoint.Message = "指定端点:"
  20.                 resFirstPoint = ed.GetPoint(optFirstPoint)
  21.                 funCount = 2
  22.             End If
  23.             If resFirstPoint.Status  PromptStatus.OK Then Return
  24.             sPt = resFirstPoint.Value
  25.             sPt = sPt.TransformBy(ed.CurrentUserCoordinateSystem)'===第一个矩阵===
  26.             ePt = sPt
  27.             ent = New Line(sPt, ePt)
  28.             Dim resJigPoint As PromptResult = ed.Drag(Me)
  29.             If resJigPoint.Status = PromptStatus.OK Then
  30.                 AppendEntity(ent)
  31.             End If
  32.             ent.Dispose()
  33.             funCount = 1
  34.         End Sub
  35.         Protected Overrides Function Sampler(ByVal prompts As Autodesk..EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus
  36.             Dim Message As String = IIf(funCount = 1, "指定端点:", "指定中点:")
  37.             Dim optJigPoint As New JigPromptPointOptions(vbCrLf & Message)
  38.             With optJigPoint
  39.                 .BasePoint = sPt
  40.                 .UseBasePoint = True
  41.                 .UserInputControls = UserInputControls.Accept3dCoordinates
  42.             End With
  43.             Dim resJigPoint As PromptPointResult = prompts.AcquirePoint(optJigPoint)
  44.             If resJigPoint.Status  PromptStatus.OK Then Return SamplerStatus.Cancel
  45.             ePt = resJigPoint.Value
  46.             ePt = ePt.TransformBy(Matrix3d.Identity)'===第二个矩阵===
  47.             If sPt = ePt Then Return SamplerStatus.NoChange
  48.             If funCount = 1 Then
  49.                 ent.EndPoint = ePt
  50.                 ent.StartPoint = sPt + (sPt - ePt)
  51.             Else
  52.                 ent.StartPoint = sPt
  53.                 ent.EndPoint = sPt + 2 * (ePt - sPt)
  54.             End If
  55.             Return SamplerStatus.OK
  56.         End Function
  57.         Protected Overrides Function WorldDraw(ByVal draw As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean
  58.             draw.Geometry.Draw(ent)
  59.             Return True
  60.         End Function
  61.     End Class

回复

使用道具 举报

8

主题

26

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
58
发表于 2011-8-16 21:13:00 | 显示全部楼层
原来第二个矩阵处的这行代码可以取消,没意义的。
是否可以这样理解:ed.GetPoint获得的是UCS坐标,而prompts.AcquirePoint获得的是WCS坐标?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-15 16:19 , Processed in 0.598221 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表