<?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 Re: Problem with UCS vectors in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651942#M66345</link>
    <description>Thanks a lot, it worked like a charm!&lt;BR /&gt;
&lt;BR /&gt;
I knew that a third point was needed but you solved it like I tried, with keeping the zAxis as in the previous UCS.&lt;BR /&gt;
&lt;BR /&gt;
But now I have another question, how to "plan" the new UCS? (Like the PLAN command in AutoCAD). Is it to create a new view? Can you point me in some direction or even better give me a sample?</description>
    <pubDate>Sat, 20 Mar 2010 08:56:27 GMT</pubDate>
    <dc:creator>hericson</dc:creator>
    <dc:date>2010-03-20T08:56:27Z</dc:date>
    <item>
      <title>Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651940#M66343</link>
      <description>I can't figure out how the vectors and matrix works while changing UCS.&lt;BR /&gt;
&lt;BR /&gt;
Let's say I have two points (could be start and end point on a line), now I want to create a UCS that have the X-axis on this line between the two points. I tried the following code but I can't create the correct vectors for the x,y and z axis.&lt;BR /&gt;
&lt;BR /&gt;
      Dim mat As Matrix3d = Matrix3d.AlignCoordinateSystem(Point3d.Origin, _&lt;BR /&gt;
                                                           Vector3d.XAxis, _&lt;BR /&gt;
                                                           Vector3d.YAxis, _&lt;BR /&gt;
                                                           Vector3d.ZAxis, _&lt;BR /&gt;
                                                           originPoint, _&lt;BR /&gt;
                                                           xAxisVec, _&lt;BR /&gt;
                                                           yAxisVec, _&lt;BR /&gt;
                                                           zAxisVec)&lt;BR /&gt;
&lt;BR /&gt;
      ed.CurrentUserCoordinateSystem = mat&lt;BR /&gt;
&lt;BR /&gt;
Please, help!</description>
      <pubDate>Fri, 19 Mar 2010 21:01:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651940#M66343</guid>
      <dc:creator>hericson</dc:creator>
      <dc:date>2010-03-19T21:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651941#M66344</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Two points aren't enough to define a coordinate system.&lt;BR /&gt;
A third data is needed, as a third point or a vector.&lt;BR /&gt;
The way AutoCAD works to "Accept" after two user inputs (points) in the UCS command is keeping the same ZAxis vector as prvious UCS.&lt;BR /&gt;
&lt;BR /&gt;
The following routine works this way:&lt;BR /&gt;
&lt;BR /&gt;
{code}private void SetUcsBy2Points(Point3d pt1, Point3d pt2)&lt;BR /&gt;
        {&lt;BR /&gt;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
            Vector3d zAxis = ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis;&lt;BR /&gt;
            Vector3d xAxis = pt1.GetVectorTo(pt2).GetNormal();&lt;BR /&gt;
            Vector3d yAxis = zAxis.CrossProduct(xAxis).GetNormal();&lt;BR /&gt;
            Matrix3d mat = Matrix3d.AlignCoordinateSystem(&lt;BR /&gt;
                Point3d.Origin,&lt;BR /&gt;
                Vector3d.XAxis,&lt;BR /&gt;
                Vector3d.YAxis,&lt;BR /&gt;
                Vector3d.ZAxis,&lt;BR /&gt;
                pt1,&lt;BR /&gt;
                xAxis,&lt;BR /&gt;
                yAxis,&lt;BR /&gt;
                zAxis);&lt;BR /&gt;
            ed.CurrentUserCoordinateSystem = mat;&lt;BR /&gt;
        }{code}</description>
      <pubDate>Sat, 20 Mar 2010 08:46:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651941#M66344</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2010-03-20T08:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651942#M66345</link>
      <description>Thanks a lot, it worked like a charm!&lt;BR /&gt;
&lt;BR /&gt;
I knew that a third point was needed but you solved it like I tried, with keeping the zAxis as in the previous UCS.&lt;BR /&gt;
&lt;BR /&gt;
But now I have another question, how to "plan" the new UCS? (Like the PLAN command in AutoCAD). Is it to create a new view? Can you point me in some direction or even better give me a sample?</description>
      <pubDate>Sat, 20 Mar 2010 08:56:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651942#M66345</guid>
      <dc:creator>hericson</dc:creator>
      <dc:date>2010-03-20T08:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651943#M66346</link>
      <description>IMO, the easyest way is to set UCSFOLLOW to 1 before changing UCS.</description>
      <pubDate>Sat, 20 Mar 2010 09:02:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651943#M66346</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2010-03-20T09:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651944#M66347</link>
      <description>Smart solution! Thanks again.</description>
      <pubDate>Sat, 20 Mar 2010 09:10:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651944#M66347</guid>
      <dc:creator>hericson</dc:creator>
      <dc:date>2010-03-20T09:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with UCS vectors</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651945#M66348</link>
      <description>Here's a safer implementation which will work even if the pt1 to pt2 vector in colinear to the current UCS Z axis.&lt;BR /&gt;
It also use anothe way to build the matrix.&lt;BR /&gt;
&lt;BR /&gt;
{code}private void SetUcsBy2Points(Point3d pt1, Point3d pt2)&lt;BR /&gt;
        {&lt;BR /&gt;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
            CoordinateSystem3d ucs = ed.CurrentUserCoordinateSystem.CoordinateSystem3d;&lt;BR /&gt;
            Vector3d zAxis = ucs.Zaxis;&lt;BR /&gt;
            Vector3d xAxis = pt1.GetVectorTo(pt2).GetNormal();&lt;BR /&gt;
            Vector3d yAxis;&lt;BR /&gt;
            if (xAxis.IsEqualTo(zAxis))&lt;BR /&gt;
            {&lt;BR /&gt;
                yAxis = ucs.Yaxis;&lt;BR /&gt;
                zAxis = xAxis.CrossProduct(yAxis).GetNormal();&lt;BR /&gt;
            }&lt;BR /&gt;
            else&lt;BR /&gt;
            {&lt;BR /&gt;
                yAxis = zAxis.CrossProduct(xAxis).GetNormal();&lt;BR /&gt;
            }&lt;BR /&gt;
            Matrix3d mat = new Matrix3d(new double[]{&lt;BR /&gt;
                xAxis.X, yAxis.X, zAxis.X, pt1.X,&lt;BR /&gt;
                xAxis.Y, yAxis.Y, zAxis.Y, pt1.Y,&lt;BR /&gt;
                xAxis.Z, yAxis.Z, zAxis.Z, pt1.Z,&lt;BR /&gt;
                0.0, 0.0, 0.0, 1.0});&lt;BR /&gt;
            ed.CurrentUserCoordinateSystem = mat;&lt;BR /&gt;
        }{code}</description>
      <pubDate>Sat, 20 Mar 2010 10:53:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-ucs-vectors/m-p/2651945#M66348</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2010-03-20T10:53:29Z</dc:date>
    </item>
  </channel>
</rss>

