Skip to content

Commit

Permalink
update create section:
Browse files Browse the repository at this point in the history
orient lines
  • Loading branch information
GLOBAL\Giovanni.Brogiolo committed Apr 14, 2021
1 parent 5427e73 commit 569db8b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion ReviTab/Commands/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,24 @@ public static ViewSection CreateSectionParallel(Document doc, UIDocument uidoc,
Grid grid = lineBasedElement as Grid;
line = grid.Curve as Line;
}



//ORIENT LINES: https://forums.autodesk.com/t5/revit-api-forum/parallel-line/m-p/7662821/highlight/true#M27606
XYZ xyzDir = null;
xyzDir = line.Direction.Normalize();

if (((Math.Abs(xyzDir.X) >= Math.Abs(xyzDir.Y)) && xyzDir.X < 0) || ((Math.Abs(xyzDir.Y) > Math.Abs(xyzDir.X)) && xyzDir.Y < 0))
{
line = line.CreateReversed() as Line;

}
else
{

}



XYZ p = line.GetEndPoint(0);
XYZ q = line.GetEndPoint(1);
XYZ v = p - q; // p point 0 - q point 1 - view direction up.
Expand All @@ -417,6 +434,17 @@ public static ViewSection CreateSectionParallel(Document doc, UIDocument uidoc,
XYZ walldir = v.Normalize();





//ORIENT TO 1,0,0 OR 0,1,0
//XYZ xdir = walldir.CrossProduct(new XYZ(1, 0, 0));
//XYZ ydir = walldir.CrossProduct(new XYZ(0, 1, 0));
//if ( xdir.X+xdir.Y == 0 || ydir.X+ydir.Y == 0)
//{
// walldir = new XYZ(-Math.Abs(walldir.X), -Math.Abs(walldir.Y), -Math.Abs(walldir.Z));
//}

if (flipDirection)
{
walldir = -walldir;
Expand Down

0 comments on commit 569db8b

Please sign in to comment.