- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
After successfully getting my Flow arrows to come into the model to match the pipe curve elevation, now I am trying to get the Flow arrow to align with to end point of the pipe using the ElementTransformUtils.RotateElement method. Currently, the arrows drop into the model in the same direction the flow arrow was created in, to the left no matter what angle or direction the pipe was created in. Any advice or help would be appreciated
My thoughts are to
- get the end points of the pipe
- then get the pipe direction and normalize it
- Get the rotation axis
- get the angle
- then use the ElementformsUtils method.
//Code to create flow arrow on the Curve of the pipe
var placedArrow = document.Create.NewFamilyInstance(point, flowArrow, document.GetElement(levelId) as Level, StructuralType.NonStructural);
//Code to correct the insertion elevation of the object
document.Regenerate();
LocationPoint arrowLocationPoint = placedArrow.Location as LocationPoint;
XYZ location = arrowLocationPoint.Point;
XYZ differencePoint = new XYZ(point.X - location.X, point.Y - location.Y, point.Z - location.Z);
placedArrow.Location.Move(new XYZ(differencePoint.X, differencePoint.Y, differencePoint.Z));
//Rotate to match Pipe curve
XYZ pipeStartPoint = pipeCurve.GetEndPoint(0);
XYZ pipeEndPoint = pipeCurve.GetEndPoint(1);
XYZ pipeDirection = (pipeEndPoint - pipeStartPoint).Normalize();
Line rotationAxis = Line.CreateBound(pipeStartPoint, pipeEndPoint);
double rotationAngle = pipeCurve.ComputeDerivatives(0, true).BasisZ.AngleOnPlaneTo(pipeEndPoint, pipeDirection);
ElementTransformUtils.RotateElement(document, placedArrow.Id, rotationAxis, rotationAngle);
transaction.Commit();
If you want to see the full code here is my gitHub page:
https://github.com/cabowker/FlowArrows
Also, I attached a 2023 model with flow-arrow family and pipe.
Solved! Go to Solution.