Hello: I'm trying to find the angle between 2 lines; however, I've been running into difficulties.
Take a look at the first pic below, you will see the angle i would like to find ....it's the 112 degree angle that's inside the polygon -between the 2 red lines.
To get the angle, I'm getting the difference between each line angle; however, I found that depending on which dirrection the line was drawn will give me different results. e.g. Take a look at my second pic - the 2 lines are identified in red. The angle of the top red line is 0 and the other red line is 292. Clearly the differnce between these 2 angles is not 112; however, if i redraw the red line w/ the angle of 0 in a different direction, i get 180. therefore, 292-180=112.
I thought that i would therefore try to use this code I got from the AutoCAD .NET Developer's Guide - for creating an Angular Dimension to see if it would give me the correct angle, but It's not working correctly (see pic 3 that shows the output).
Here's the code:
<CommandMethod("CreateAngularDimension")> _
Public Sub CreateAngularDimension(myPreviousLine,myLine)
'' Get the current database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
'' Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
'' Create an angular dimension
Dim acLinAngDim As LineAngularDimension2 = New LineAngularDimension2()
acLinAngDim.SetDatabaseDefaults()
acLinAngDim.XLine1Start = New Point3d(myLine.startpoint.x, myLine.startpoint.y, 0)
acLinAngDim.XLine1End = New Point3d(myLine.endpoint.x, myLine.endpoint.y, 0)
acLinAngDim.XLine2Start = New Point3d(myPreviousLine.startpoint.x, myPreviousLine.startpoint.y, 0)
acLinAngDim.XLine2End = New Point3d(myPreviousLine.endpoint.x, myPreviousLine.endpoint.y, 0)
acLinAngDim.ArcPoint = New Point3d(3, 5, 0)
acLinAngDim.DimensionStyle = acCurDb.Dimstyle
'' Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acLinAngDim)
acTrans.AddNewlyCreatedDBObject(acLinAngDim, True)
'' Commit the changes and dispose of the transaction
acTrans.Commit()
End Using
End Sub
I was hoping someone might know why the angle is drawing on the outside of the poly and therefore not giving me the correct angle (112)....from looking at this code? Or, perhaps there's a better way to do this?
Thank you for your input,
Proctor