<?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: Rotate ViewSection using a transforms view direction in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7620083#M54012</link>
    <description>&lt;P&gt;The section box can have any conformal transform. You can create it, for example via multiplication of any numbers of simple transforms, such as rotation, reflection, translation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've recently wrote creation of section boxes for each wall in room. Look at this is the part of the code:&lt;/P&gt;&lt;PRE&gt;private static BoundingBoxXYZ CreateSectionBoundingBox(XYZ startPoint, XYZ endPoint, double height)
{
	var length = (endPoint - startPoint).GetLength();

	return new BoundingBoxXYZ
		{
			Min = XYZ.Zero,
			Max = new XYZ(length, height, 1),
			Transform = CreateSectionTransform(startPoint, endPoint)
		};
}

private static Transform CreateSectionTransform(XYZ startPoint, XYZ endPoint)
{
	var direction = endPoint - startPoint;

	var angle = XYZ.BasisX.AngleOnPlaneTo(direction, XYZ.BasisZ);

	var shiftInsideRoomLenght = UnitUtils.ConvertToInternalUnits(300, DisplayUnitType.DUT_MILLIMETERS);

	var shiftInsideRoomDirection = direction.CrossProduct(XYZ.BasisZ).Normalize();

	return Transform.CreateTranslation(startPoint + shiftInsideRoomLenght * shiftInsideRoomDirection)
		   *Transform.CreateRotation(XYZ.BasisX, 0.5*Math.PI)
		   *Transform.CreateRotation(XYZ.BasisY, angle + Math.PI)
		   *Transform.CreateTranslation(-XYZ.BasisX*direction.GetLength());
}&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Dec 2017 12:59:58 GMT</pubDate>
    <dc:creator>aignatovich</dc:creator>
    <dc:date>2017-12-13T12:59:58Z</dc:date>
    <item>
      <title>Rotate ViewSection using a transforms view direction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7619862#M54009</link>
      <description>&lt;P&gt;Hi, I am creating a ViewScetion from a bounding Box, I used the below code to get a transform working, however I would like the section orientation to be at 90 degrees to what it is at the moment. Currently the view section cut is ok, it cuts in plan and the view section marker is visible however i'd like it rotated in plan view by pi/2.&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This is how i get the view direction currently!&lt;/P&gt;&lt;P&gt;//TRANSFORM - set&amp;nbsp;&lt;BR /&gt;Transform trans = Transform.Identity;&lt;/P&gt;&lt;P&gt;//ORIGIN - set&lt;BR /&gt;XYZ farPt = boundbox.Max;&lt;BR /&gt;trans.Origin = farPt;&lt;/P&gt;&lt;P&gt;//VIEW DIRECTION&lt;BR /&gt;trans.BasisX = -XYZ.BasisX;&lt;BR /&gt;trans.BasisY = XYZ.BasisZ;&lt;BR /&gt;trans.BasisZ = XYZ.BasisY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;sectionbox.Transform = trans;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 11:45:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7619862#M54009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-13T11:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rotate ViewSection using a transforms view direction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7619987#M54010</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;trans.BasisX = XYZ.BasisY;
trans.BasisY = XYZ.BasisZ;
trans.BasisZ = XYZ.BasisX; // or -1*XYZ.BasisX&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In general BasisZ will be your section direction, BasisX is your section line direction (in plan, for example), BasisY should be orthogonal to BasisZ and BasisX&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 12:33:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7619987#M54010</guid>
      <dc:creator>aignatovich</dc:creator>
      <dc:date>2017-12-13T12:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Rotate ViewSection using a transforms view direction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7620031#M54011</link>
      <description>&lt;P&gt;Thanx, I even tried random attempts and there cant be that many 9? with the signs maybe 12?&lt;/P&gt;&lt;P&gt;I will definitely memorize this info!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 12:45:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7620031#M54011</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-13T12:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rotate ViewSection using a transforms view direction</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7620083#M54012</link>
      <description>&lt;P&gt;The section box can have any conformal transform. You can create it, for example via multiplication of any numbers of simple transforms, such as rotation, reflection, translation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've recently wrote creation of section boxes for each wall in room. Look at this is the part of the code:&lt;/P&gt;&lt;PRE&gt;private static BoundingBoxXYZ CreateSectionBoundingBox(XYZ startPoint, XYZ endPoint, double height)
{
	var length = (endPoint - startPoint).GetLength();

	return new BoundingBoxXYZ
		{
			Min = XYZ.Zero,
			Max = new XYZ(length, height, 1),
			Transform = CreateSectionTransform(startPoint, endPoint)
		};
}

private static Transform CreateSectionTransform(XYZ startPoint, XYZ endPoint)
{
	var direction = endPoint - startPoint;

	var angle = XYZ.BasisX.AngleOnPlaneTo(direction, XYZ.BasisZ);

	var shiftInsideRoomLenght = UnitUtils.ConvertToInternalUnits(300, DisplayUnitType.DUT_MILLIMETERS);

	var shiftInsideRoomDirection = direction.CrossProduct(XYZ.BasisZ).Normalize();

	return Transform.CreateTranslation(startPoint + shiftInsideRoomLenght * shiftInsideRoomDirection)
		   *Transform.CreateRotation(XYZ.BasisX, 0.5*Math.PI)
		   *Transform.CreateRotation(XYZ.BasisY, angle + Math.PI)
		   *Transform.CreateTranslation(-XYZ.BasisX*direction.GetLength());
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Dec 2017 12:59:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/rotate-viewsection-using-a-transforms-view-direction/m-p/7620083#M54012</guid>
      <dc:creator>aignatovich</dc:creator>
      <dc:date>2017-12-13T12:59:58Z</dc:date>
    </item>
  </channel>
</rss>

