Jigging a line with unexcpected results.
to test a function I have jigged a regular line and writen the angle to
the command line to check the lines returned angle.
The problem is it counts OK from 0 > 180, but when you go past that it then counts
backwards from 180 > 0. obviously I was expecting 0 > 360 degrees.
Has anyone else seen this, is it a bug?
Imports Teigha.Runtime
Imports Teigha.DatabaseServices
Imports Teigha.Geometry
Imports Bricscad.ApplicationServices
Imports Bricscad.EditorInput
Imports Teigha
Imports Bricscad
Public Class Temp
Inherits EditorInput.DrawJig
Dim EndPt As Point3d
Dim myPR As PromptPointResult
Dim myPER As PromptEntityResult
Dim StPnt As Point3d ' Centre of selection
Function StartJig() As PromptPointResult
' Get Doc
Dim myDWG As Document = Application.DocumentManager.MdiActiveDocument
Dim myEd As Editor = myDWG.Editor
Dim GetPntOpts As New PromptPointOptions(vbCr & "Select insert:")
Dim GetPnt As PromptPointResult = myEd.GetPoint(GetPntOpts)
StPnt = GetPnt.Value
myPR = myEd.Drag(Me)
Do
Select Case myPR.Status
Case PromptStatus.OK
Return myPR
Exit Do
End Select
Loop While myPR.Status <> PromptStatus.Cancel
Return myPR
End Function
Protected Overrides Function Sampler(ByVal prompts As JigPrompts) As SamplerStatus
Dim jigOpts As JigPromptPointOptions = New JigPromptPointOptions(vbLf & "Select insert point:")
myPR = prompts.AcquirePoint(jigOpts)
If myPR.Value.IsEqualTo(EndPt) Then
Return SamplerStatus.NoChange
Else
EndPt = myPR.Value
Return SamplerStatus.OK
End If
End Function
Protected Overrides Function WorldDraw(ByVal draw As GraphicsInterface.WorldDraw) As Boolean
' Get Doc
Dim myDWG As Document = Application.DocumentManager.MdiActiveDocument
Dim myEd As Editor = myDWG.Editor
' Endpoint of Drag Line
Dim CntLine As Line = New Line(StPnt, EndPt)
If CntLine.Angle > ToRad(0) And CntLine.Angle <= ToRad(180) = True Then<br> CntLine.ColorIndex = 1
Else
CntLine.ColorIndex = 4
End If
draw.Geometry.Draw(CntLine)
myEd.WriteMessage(vbCr & CntLine.Angle.ToString)
' Dispose
CntLine.Dispose()
End Function
_
Public Sub Roundabout_ExitArm()
Try
' Start Jig
Dim myJig As New Temp
Dim SelPt As PromptPointResult
SelPt = myJig.StartJig()
Catch ex As System.Exception
End Try
End Sub
End Class
Comments
-
My guess is you need to use the line's Delta and a reference vector, see
[code]
[CommandMethod("doit2", CommandFlags.Session)]
static public void doit2()
{
AcAp.Document doc = AcAp.Application.DocumentManager.MdiActiveDocument;
Matrix3d xfrm = doc.Editor.CurrentUserCoordinateSystem;
PromptPointOptions ppo = new PromptPointOptions("get next Point");
ppo.UseBasePoint = true;
ppo.BasePoint = doc.Editor.GetPoint("get start Point").Value;
PromptPointResult ppr = doc.Editor.GetPoint(ppo);
Line line = new Line(ppo.BasePoint, ppr.Value);
//use a reference vector
double ang1 = line.Delta.GetAngleTo(
xfrm.CoordinateSystem3d.Xaxis, xfrm.CoordinateSystem3d.Zaxis);
//no reference vector
double ang2 = line.Angle;
//
doc.Editor.WriteMessage("\n{0}-{1}", ang1, ang2);
}
[/code]
Also, don't create a new line in each call to WorldDraw as it will use up resources, make the line a member of your class, or better yet, use the geometry provided in worldDraw
Cheers : )
0 -
Thanks for the help,
that does provide a work around, but shouldn't the correct angle come from the line?
Is this a bug?
Cheers again,
Martin.0