<?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: Grids Off-Axis in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7130898#M57970</link>
    <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you notice the blog post last week on how to modify grid curve end points?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/05/sdk-update-rvtsamples-and-modifying-grid-end-point.html#4" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/05/sdk-update-rvtsamples-and-modifying-grid-end-point.html#4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That looks as if it might be exactly what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2017 07:05:05 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2017-06-06T07:05:05Z</dc:date>
    <item>
      <title>Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7129065#M57969</link>
      <description>&lt;P&gt;I have models with Grids having off-axis warnings. Snooping the Grid.Lines shows direction vectors that are microscopically off horizontal/vertical. I have been unsuccessful in changing the&amp;nbsp;XYZ&amp;nbsp;.Direction (read only). Just to prove I tried unsuccessfully, even if it is daft:&lt;/P&gt;
&lt;PRE&gt;// get the current grid location
LocationCurve location = grid.Location as LocationCurve;
// get the points
XYZ pt1 = location.Curve.GetEndPoint(0);
XYZ pt2 = location.Curve.GetEndPoint(1);
// make x values equal
pt2 = pt2.Add(new XYZ(pt1.X, pt2.Y, pt2.Z));
// create a new LineBound
//Line line = createApp.NewLineBound( // 2013 
Line newGridLine = Line.CreateBound(pt1, pt2);
// update the grid curve
location.Curve = newGridLine;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&amp;nbsp;was a Building Coder comment from 4 years ago:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Hello Jeremy,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;This is the closest snippet of a conversation I could find related to modifying existing Grids.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;I am trying to modify a Grid line by changing the underlying curve (line or arc) or setting the grid to a newly defined curve. Is this even possible?&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;-Nate&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Dear Nate,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Sorry, currently that does not seem possible. I added a note of your request to the existing wish list item SPR #151715 [API functionality request: to change Grid's start/end point coordinates via API].&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Cheers, Jeremy&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, is it now possible to adjust the direction vector, or the start/end points to resolve the off-axis error?&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 13:17:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7129065#M57969</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2017-06-05T13:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7130898#M57970</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you notice the blog post last week on how to modify grid curve end points?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/05/sdk-update-rvtsamples-and-modifying-grid-end-point.html#4" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/05/sdk-update-rvtsamples-and-modifying-grid-end-point.html#4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That looks as if it might be exactly what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 07:05:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7130898#M57970</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-06T07:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7134210#M57971</link>
      <description>&lt;P&gt;Indeed Jeremy, I did miss that one, and it is precisely what is&amp;nbsp;required. When it is run&amp;nbsp;on a vertical grid, it works as expected. I modified&amp;nbsp;your code so that the start and end points are given the same X value (i.e. truly vertical) to remove the microscopic "off-axis". It fails here:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;// "The curve is unbound or not coincident with the original one of the datum plane"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt; grid.SetCurveInView(&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DatumExtentType&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.Model, view, newLine);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;To be clear, if&amp;nbsp;my code is run on a vertical grid (i.e. not really effecting a change, but still functionally the same), it&amp;nbsp;completes without&amp;nbsp;error.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;The main change I made to your code is:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;XYZ&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; newStart = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;XYZ&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(start.X, start.Y, start.Z);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;XYZ&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; newEnd = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;XYZ&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(start.X, end.Y, end.Z);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;A test file with faulty vertical grids can be found here: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;A href="https://tinyurl.com/ycq6cgk3" target="_self"&gt;Off-Axis Test File&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Consolas"&gt;&lt;FONT face="Consolas" size="2"&gt;For completeness, here is&amp;nbsp;my code: &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Consolas"&gt;&lt;FONT face="Consolas" size="2"&gt;// only fixes vertical or horizontal - IsVertical
        public static Result FixGridAxisByPick(UIDocument uidoc, bool IsVertical, out string pstrMsg)
        {
            Document doc = uidoc.Document;
            Selection sel = uidoc.Selection;
            Autodesk.Revit.DB.View view = doc.ActiveView;
            string lstrMsg = "Off-Axis Error Results:";

            ISelectionFilter f = new JtElementsOfClassSelectionFilter&amp;lt;Grid&amp;gt;();
            Reference elemRef = sel.PickObject(ObjectType.Element, f, "Pick a grid");
            Grid grid = doc.GetElement(elemRef) as Grid;

            IList&amp;lt;Curve&amp;gt; gridCurves = grid.GetCurvesInView(DatumExtentType.Model, view);

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Modify Grid Endpoints");

                foreach (Curve c in gridCurves)
                {
                    XYZ start = c.GetEndPoint(0);
                    XYZ end = c.GetEndPoint(1);

                    MessageBox.Show("start: "
                        + start.ToString()
                        + Environment.NewLine
                        + " end: "
                        + end.ToString());

                    //XYZ newStart = start + 10 * XYZ.BasisY;
                    //XYZ newEnd = end - 10 * XYZ.BasisY;
                    XYZ newStart = new XYZ(start.X, start.Y, start.Z);
                    XYZ newEnd = new XYZ(start.X, end.Y, end.Z);

                    MessageBox.Show("newStart: "
                        + newStart.ToString()
                        + Environment.NewLine
                        + " newEnd: "
                        + newEnd.ToString());

                    Line newLine = Line.CreateBound(newStart, newEnd);

                    // *** fails on this line ***
                    // "The curve is unbound or not coincident with the original one of the datum plane"
                    grid.SetCurveInView(DatumExtentType.Model, view, newLine);
                }
                tx.Commit();
            }
            pstrMsg = lstrMsg;
            return Result.Succeeded;
        }&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Consolas"&gt;&lt;FONT face="Consolas" size="2"&gt;I am not asking you to debug for me, but I am not able to interpret the exception message. Thanks for any advice. Dale&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 09:14:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7134210#M57971</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2017-06-07T09:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7136444#M57972</link>
      <description>&lt;P&gt;the exception message&amp;nbsp;basically says that your new curve doesn't lie on the old curve. Meaning you can't change the direction this way.&lt;/P&gt;
&lt;P&gt;The solution is to rotate the Grid with ElementTransformUtils.RotateElement().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 22:01:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7136444#M57972</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-07T22:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7136985#M57973</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;That would be a reasonable solution. I suspect that the error is not from user input, but a result of Revit's accuracy limitations and rounding issues. In my case the variation is microscopic, so determining the&amp;nbsp;relative rotation increment, rather than being able to set the absolute angle will just push the rounding error further out. This is the off-axis grid:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GridOff-AxisError.PNG" style="width: 498px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/364777i0E9D4A21044A1BDD/image-size/large?v=v2&amp;amp;px=999" role="button" title="GridOff-AxisError.PNG" alt="GridOff-AxisError.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The highlighted value should be 1.0 but this Direction property is read-only.&lt;/P&gt;
&lt;P&gt;Thanks for the reply.&lt;/P&gt;
&lt;P&gt;Dale&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 07:03:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7136985#M57973</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2017-06-08T07:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7140709#M57974</link>
      <description>&lt;P&gt;It is maybe a rounding issue, but Revit gives you a warning in the Warning-Review list, so it would be prudent to correct the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            Grid grid = doc.GetElement(sel.GetElementIds().FirstOrDefault()) as Grid;
            XYZ direction = grid.Curve.GetEndPoint(1).Subtract(grid.Curve.GetEndPoint(0)).Normalize();
            double distance2hor = direction.DotProduct(XYZ.BasisY);
            double distance2vert = direction.DotProduct(XYZ.BasisX);
            double angle = 0;&lt;BR /&gt;// maybe use another criterium then &amp;lt;0.0001
            if (Math.Abs(distance2hor) &amp;lt; 0.0001)
            {
                XYZ vector = direction.X &amp;lt; 0 ? direction.Negate() : direction;
                angle = Math.Asin(-vector.Y);
            }
            if (Math.Abs(distance2vert) &amp;lt; 0.0001)
            {
                XYZ vector = direction.Y &amp;lt; 0 ? direction.Negate() : direction;
                angle = Math.Asin(vector.X);
            }
            if (angle.CompareTo(0) != 0)
            {
                using (Transaction t = new Transaction(doc, "correctGrid"))
                {
                    t.Start();
                    ElementTransformUtils.RotateElement(doc, grid.Id, Line.CreateBound(grid.Curve.GetEndPoint(0), grid.Curve.GetEndPoint(0).Add(XYZ.BasisZ)), angle);
                    t.Commit();
                }
            }
&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 11:43:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7140709#M57974</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-09T11:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7143866#M57975</link>
      <description>&lt;P&gt;Many thanks, that has indeed resolved the error. Dale&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 05:48:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7143866#M57975</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2017-06-11T05:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7147988#M57976</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2083518"&gt;@FAIR59&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Added to The Building Coder samples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/the_building_coder_samples/compare/2018.0.133.0...2018.0.133.1" target="_blank"&gt;https://github.com/jeremytammik/the_building_coder_samples/compare/2018.0.133.0...2018.0.133.1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:02:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7147988#M57976</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-13T09:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Grids Off-Axis</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7148215#M57977</link>
      <description>&lt;P&gt;For future reference, I published a summary of this discussion here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/06/aligning-a-slightly-off-axis-grid.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/06/aligning-a-slightly-off-axis-grid.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again, Fair 59!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 10:38:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/grids-off-axis/m-p/7148215#M57977</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-13T10:38:16Z</dc:date>
    </item>
  </channel>
</rss>

