.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pick a point on a line

0 REPLIES 0
Reply
Message 1 of 1
wesbird
251 Views, 0 Replies

Pick a point on a line

Hi,
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:
[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
Get
Return _entityToDrag
End Get
Set(ByVal Value As Entity)
_entityToDrag = Value
End Set
End Property

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

Public Property Startpoint() As Point3d
Get
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)

Application.DocumentManager.MdiActiveDocument.Editor.Drag(Me)

End Function

#End Region

#Region "Drag"

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

Application.DocumentManager.MdiActiveDocument.Editor.Drag(Me)
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
Else
Return SamplerStatus.NoChange
End If
End If

End Function

#End Region

#Region "WorldDraw"

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

draw.Geometry.Draw(entityToDrag)
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







[/code]
Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost