Not able to align tag elbow with given angle If the section cuts diagnolly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is my level plan. I can successfully align a tag on the floor or when sections are cut horizontally or vertically. However, when the section is cut diagonally, I encounter difficulty in aligning the tag at the desired angle.
This is my code
IndependentTag tag = doc.GetElement(ckt.ElementId) as IndependentTag;
if (tag != null)
{
tag.LeaderEndCondition = LeaderEndCondition.Free;
XYZ baseValue = tag.LeaderEnd;
double z2 = elboworigin.Z;
double x2 = 0;
double y2 = 0;
double x1 = baseValue.X;
double y1 = baseValue.Y;
double z1 = baseValue.Z;
double angleDegrees = 45.0;
double angleRadians = angleDegrees * Math.PI / 180.0;
double deltaZ = z2 - z1;
double tanTheta = Math.Tan(angleRadians);
double Lxy = deltaZ / tanTheta;
x2 = x1 + Lxy * Math.Cos(angleRadians);
y2 = y1 + Lxy * Math.Sin(angleRadians);
XYZ ElbowPosition = new XYZ(x2, y2, ElbowOriginZ);
tag.LeaderElbow = ElbowPosition;
XYZ headerPnt = new XYZ(elboworigin.X, ElbowOriginY, ElbowOriginZ);
tag.TagHeadPosition = headerPnt;
}