<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get angle in Z axis in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-angle-in-z-axis/m-p/7486993#M29178</link>
    <description>&lt;P&gt;Hi Everyone!&lt;BR /&gt;&lt;BR /&gt;I am trying to get the angle between two lines, I have attached the image&lt;BR /&gt;For getting the angle in Z axis I have changed the ucs and then I tried to get the angle, but It has been showing the angle in xy, only ucs has been changed to specified point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim Vuline As Line = New Line(center, ptver)
               '' Add the line to the drawing
                curSpace.AppendEntity(Vuline)
                tr.AddNewlyCreatedDBObject(Vuline, True)

                
                Dim Vlline As Line = New Line(center, ptlow)
                '' Add the line to the drawing
                curSpace.AppendEntity(Vlline)
                tr.AddNewlyCreatedDBObject(Vlline, True)

 Dim vlPt1 As Point3d = Vlline.StartPoint
Dim vlPt2 As Point3d = Vlline.EndPoint
 Dim vuPt1 As Point3d = Vlline.StartPoint
Dim vuPt2 As Point3d = Vlline.EndPoint

'change use
                Dim acUCSTbl As UcsTable
                acUCSTbl = tr.GetObject(acCurDb.UcsTableId, OpenMode.ForRead)
                Dim acUCSTblRec As UcsTableRecord
                ' Check to see if the "Window_UCS" UCS table record exists
                If acUCSTbl.Has("New_UCS") = False Then
                    acUCSTblRec = New UcsTableRecord()
                    acUCSTblRec.Name = "New_UCS"
                    '' Open the UCSTable for write
                    acUCSTbl.UpgradeOpen()
                    '' Add the new UCS table record
                    acUCSTbl.Add(acUCSTblRec)
                    tr.AddNewlyCreatedDBObject(acUCSTblRec, True)
                Else
                    acUCSTblRec = tr.GetObject(acUCSTbl("New_UCS"), OpenMode.ForWrite)
                End If

                Dim StartPts = center
                Dim EndPts = New Point3d(ptver.X, ptver.Y, center.Z)
                Dim AnglePts = ptver

                Dim xVex As Vector3d
                Dim yVex As Vector3d
                Dim zVex As Vector3d
                Dim AngleCord As Matrix3d
                xVex = center.GetVectorTo(EndPts).GetNormal()
                zVex = xVex.CrossProduct(StartPts.GetVectorTo(AnglePts)).GetNormal()
                yVex = zVex.CrossProduct(xVex).GetNormal()

                AngleCord = Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, StartPts, xVex, yVex, zVex)

                acUCSTblRec.Origin = AngleCord.CoordinateSystem3d.Origin
                acUCSTblRec.XAxis = AngleCord.CoordinateSystem3d.Xaxis
                acUCSTblRec.YAxis = AngleCord.CoordinateSystem3d.Yaxis

                '' Open the active viewport
                Dim acVportTblRec As ViewportTableRecord
                acVportTblRec = tr.GetObject(acDoc.Editor.ActiveViewportId,
                                          OpenMode.ForWrite)

                '' Display the UCS Icon at the origin of the current viewport
                acVportTblRec.IconAtOrigin = True
                acVportTblRec.IconEnabled = True

                '' Set the UCS current
                acVportTblRec.SetUcs(acUCSTblRec.ObjectId)
                acDoc.Editor.UpdateTiledViewportsFromDatabase()

Dim acLinAngDimv As LineAngularDimension2 = New LineAngularDimension2()
acLinAngDimv.XLine1Start = New Point3d(vlPt1.X, vlPt1.Y, 0)
                acLinAngDimv.XLine1End = New Point3d(vlPt2.X, vlPt2.Y, 0)
                acLinAngDimv.XLine2Start = New Point3d(vuPt1.X, vuPt1.Y, 0)
                acLinAngDimv.XLine2End = New Point3d(vuPt2.X, vuPt2.Y, 0)
                'acLinAngDims.ArcPoint = New Point3d(3, 5, 0)
                acLinAngDimv.DimensionStyle = acCurDb.Dimstyle

                '' Add the new object to Model space and the transaction
                curSpace.AppendEntity(acLinAngDimv)
                tr.AddNewlyCreatedDBObject(acLinAngDimv, True)&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;could anyone guide me, how to changed the code to achieve the result..&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2017 13:39:54 GMT</pubDate>
    <dc:creator>waseefur.rahman</dc:creator>
    <dc:date>2017-10-24T13:39:54Z</dc:date>
    <item>
      <title>Get angle in Z axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-angle-in-z-axis/m-p/7486993#M29178</link>
      <description>&lt;P&gt;Hi Everyone!&lt;BR /&gt;&lt;BR /&gt;I am trying to get the angle between two lines, I have attached the image&lt;BR /&gt;For getting the angle in Z axis I have changed the ucs and then I tried to get the angle, but It has been showing the angle in xy, only ucs has been changed to specified point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim Vuline As Line = New Line(center, ptver)
               '' Add the line to the drawing
                curSpace.AppendEntity(Vuline)
                tr.AddNewlyCreatedDBObject(Vuline, True)

                
                Dim Vlline As Line = New Line(center, ptlow)
                '' Add the line to the drawing
                curSpace.AppendEntity(Vlline)
                tr.AddNewlyCreatedDBObject(Vlline, True)

 Dim vlPt1 As Point3d = Vlline.StartPoint
Dim vlPt2 As Point3d = Vlline.EndPoint
 Dim vuPt1 As Point3d = Vlline.StartPoint
Dim vuPt2 As Point3d = Vlline.EndPoint

'change use
                Dim acUCSTbl As UcsTable
                acUCSTbl = tr.GetObject(acCurDb.UcsTableId, OpenMode.ForRead)
                Dim acUCSTblRec As UcsTableRecord
                ' Check to see if the "Window_UCS" UCS table record exists
                If acUCSTbl.Has("New_UCS") = False Then
                    acUCSTblRec = New UcsTableRecord()
                    acUCSTblRec.Name = "New_UCS"
                    '' Open the UCSTable for write
                    acUCSTbl.UpgradeOpen()
                    '' Add the new UCS table record
                    acUCSTbl.Add(acUCSTblRec)
                    tr.AddNewlyCreatedDBObject(acUCSTblRec, True)
                Else
                    acUCSTblRec = tr.GetObject(acUCSTbl("New_UCS"), OpenMode.ForWrite)
                End If

                Dim StartPts = center
                Dim EndPts = New Point3d(ptver.X, ptver.Y, center.Z)
                Dim AnglePts = ptver

                Dim xVex As Vector3d
                Dim yVex As Vector3d
                Dim zVex As Vector3d
                Dim AngleCord As Matrix3d
                xVex = center.GetVectorTo(EndPts).GetNormal()
                zVex = xVex.CrossProduct(StartPts.GetVectorTo(AnglePts)).GetNormal()
                yVex = zVex.CrossProduct(xVex).GetNormal()

                AngleCord = Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, StartPts, xVex, yVex, zVex)

                acUCSTblRec.Origin = AngleCord.CoordinateSystem3d.Origin
                acUCSTblRec.XAxis = AngleCord.CoordinateSystem3d.Xaxis
                acUCSTblRec.YAxis = AngleCord.CoordinateSystem3d.Yaxis

                '' Open the active viewport
                Dim acVportTblRec As ViewportTableRecord
                acVportTblRec = tr.GetObject(acDoc.Editor.ActiveViewportId,
                                          OpenMode.ForWrite)

                '' Display the UCS Icon at the origin of the current viewport
                acVportTblRec.IconAtOrigin = True
                acVportTblRec.IconEnabled = True

                '' Set the UCS current
                acVportTblRec.SetUcs(acUCSTblRec.ObjectId)
                acDoc.Editor.UpdateTiledViewportsFromDatabase()

Dim acLinAngDimv As LineAngularDimension2 = New LineAngularDimension2()
acLinAngDimv.XLine1Start = New Point3d(vlPt1.X, vlPt1.Y, 0)
                acLinAngDimv.XLine1End = New Point3d(vlPt2.X, vlPt2.Y, 0)
                acLinAngDimv.XLine2Start = New Point3d(vuPt1.X, vuPt1.Y, 0)
                acLinAngDimv.XLine2End = New Point3d(vuPt2.X, vuPt2.Y, 0)
                'acLinAngDims.ArcPoint = New Point3d(3, 5, 0)
                acLinAngDimv.DimensionStyle = acCurDb.Dimstyle

                '' Add the new object to Model space and the transaction
                curSpace.AppendEntity(acLinAngDimv)
                tr.AddNewlyCreatedDBObject(acLinAngDimv, True)&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;could anyone guide me, how to changed the code to achieve the result..&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 13:39:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-angle-in-z-axis/m-p/7486993#M29178</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-10-24T13:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get angle in Z axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-angle-in-z-axis/m-p/7487558#M29179</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4333282"&gt;@waseefur.rahman&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi Everyone!&lt;BR /&gt;&lt;BR /&gt;I am trying to get the angle between two lines, I have attached the image&lt;BR /&gt;For getting &lt;FONT color="#FF0000"&gt;the angle in Z axis&lt;/FONT&gt; I have changed the ucs and then I tried to get the angle, but It has been showing the angle in xy, only ucs has been changed to specified point.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm not sure I understand what '&lt;SPAN&gt;the angle in Z axis' means. Do you mean the angle in the XZ or YZ plane?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, the angle between any two lines in 3D space in the plane that both lines lie in:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Line line1 = ....
Line line2 = ....
&lt;BR /&gt;Vector3d v1 = line1.StartPoint.GetVectorTo(line1.EndPoint);
Vector3d v2 = line2.StartPoint.GetVectorTo(line2.EndPoint);

&lt;BR /&gt;double angle = v1.GetAngleTo(v2);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the angle of a line in the XZ plane, from the X axis:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Line line = ... (lies in the XZ plane)

Vector3d vector = line.StartPoint.GetVectorTo(Line.EndPoint);

double angle = Vector3d.XAxis.GetAngleTo(vector);

;; or where the line is in the YZ plane:

double angle = Vector3d.YAxis.GetAngleTo(vector);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the angle of a line in any plane that's parallel to the Z axis, you can use the same method as the above, to find the angle between the line and the Z axis (Vector3d.ZAxis), and the difference between that and 90 degrees is the angle of the line (e.g., the 'slope') from the XY plane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 16:28:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-angle-in-z-axis/m-p/7487558#M29179</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-10-24T16:28:10Z</dc:date>
    </item>
  </channel>
</rss>

