var angle = wallOrientation.AngleTo(XYZ.BasisY);
if (Math.Abs(wallOrientation.DotProduct(XYZ.BasisY) - 1) < 0.0001)
{
// lifehack =))
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI / 2);
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI / 2);
}
else if (Math.Abs(wallOrientation.DotProduct(XYZ.BasisY) - 1) > 0.0001)
{
if (wallOrientation.Y > 0.0)
{
if (wallOrientation.X > 0.0)
{
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), -angle);
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI / 2);
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI / 2);
}
else ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI + angle);
}
else
{
if (wallOrientation.X > 0.0)
ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), Math.PI - angle);
else ElementTransformUtils.RotateElement(doc, marker.Id, Line.CreateUnbound(markerPosition, XYZ.BasisZ), angle);
}
}