Distinguished Contributor
368 Posts
0 Kudos
Registered: ‎12-05-2003
Post 1 of 1

Pick a point on a line

105 Views, 0 Replies
04-27-2006 06:10 PM
I know the start point and angle, I want my user to pick the end point on the screen. I am using to jig to do it. I attach the code below. something like LENGTHEN command DYnamic option.
I draw the line, in the Jig.Sampler, I tried to use scale matrix transfer, but I did not get what I want. Is what I thought correct? Thank you if you can point me the right direction.

here is the code:
Imports System

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.GraphicsInterface
Imports Autodesk.AutoCAD.ApplicationServices

Public Class JigLine
Inherits DrawJig

#Region "private member fields"

Private gptIns As Point3d

Private pAngle As Double
Private cAngle As Double
Private _StartPoint As New Point3d(0, 0, 0)
Private _OldEndPoint As Point3d
Private _NewEndPoint As Point3d

Private _entityToDrag As Entity

Public Sub New()

End Sub

#End Region

#Region "property"

Public Property entityToDrag() As Entity
Return _entityToDrag
End Get
Set(ByVal Value As Entity)
_entityToDrag = Value
End Set
End Property

Public Property Angle() As Double
Return cAngle
End Get
Set(ByVal Value As Double)
cAngle = Value
End Set
End Property

Public Property Startpoint() As Point3d
Return _StartPoint
End Get
Set(ByVal Value As Point3d)
_StartPoint = Value
End Set
End Property

#End Region

#Region "JigLine"

Public Function StartJig()

Dim EndPoint As Point3d
pAngle = Math.PI / 3.5
EndPoint = New Point3d(_StartPoint.X + Math.Cos(pAngle) * 10, _
_StartPoint.Y + Math.Sin(pAngle) * 10, 0)
_OldEndPoint = EndPoint

_entityToDrag = New Line(_StartPoint, EndPoint)


End Function

#End Region

#Region "Drag"

Public Function Drag()
If _entityToDrag Is Nothing Then
Throw New Exception("JigLine.Drag._entityToDrag")
End If

End Function

#End Region

#Region "Sample"

Protected Overrides Function Sampler(ByVal prompts As JigPrompts) As SamplerStatus

Dim jigOpts As JigPromptOptions = New JigPromptOptions
jigOpts.Message = "\n Select End Point: "
jigOpts.BasePoint = _StartPoint
jigOpts.UseBasePoint = True

Dim rot As PromptPointResult = prompts.AcquirePoint(jigOpts)
If rot.Status = PromptStatus.None Then
Return SamplerStatus.OK
End If

_NewEndPoint = rot.Value
If Not _NewEndPoint.Equals(_StartPoint) Then

If CursorHasMoved() Then
' rotate
Dim scale As Double = _StartPoint.DistanceTo(_NewEndPoint) / 10

entityToDrag.TransformBy(Matrix3d.Scaling(scale, _StartPoint))

_OldEndPoint = _NewEndPoint

Return SamplerStatus.OK
Return SamplerStatus.NoChange
End If
End If

End Function

#End Region

#Region "WorldDraw"

Protected Overrides Function WorldDraw(ByVal draw As WorldDraw) As Boolean

Return True

End Function

#End Region

#Region "CursorHasMoved "

Private Function CursorHasMoved() As Boolean

Dim myTolerance As Tolerance = New Tolerance(0.001, 0.01)

Return Not (_OldEndPoint.Equals(_NewEndPoint))

End Function

#End Region

End Class

Vault Pro 2014, Windows 7 64 bit, AutoCAD (ACA, Map) 2014
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!