Distinguished Contributor
Posts: 351
Registered: ‎12-05-2003
Message 1 of 1 (100 Views)

Pick a point on a line

100 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

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.