I have a section marker for which I would like to do a rotation around one of the endpoints of the line segment leader but I haven't been able to figure out how to get the coordinates of the endpoint. I'm able to get the bounding box of the overall section marker but not these specific coordinates. How can I do this?
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Skeletank,
I am checking with the development team for you... hang on...
Cheers,
Jeremy
Hi Jeremy,
Have you heard anything back from the development team? My bigger problem involves reversing the effects of the built-in "Mirror Project" tool and part of that includes reference section markers inside of another section that has been flipped. I would like to fix their orientation by rotating 180 degrees around the endpoint.
Thanks
Yes.
They say:
1. The section marker element is not exposed as a specific element type so I don’t think this position can be read at this time.
2. Regarding “Mirror Project”: I don’t have good ideas to add.
Sorry for not being of more help!
Cheers,
Jeremy
I was assuming that would be the response but thank you very much Jeremy for checking with the development team for me.
I've found a workaround for your question
A transaction needs to be active when you call the method, as the method hides the section tag and viewer_reference_label_text temporarily.
private Line GetSectionLine(Element _section, Autodesk.Revit.DB.View _view) { const double _correction = 21.130014403 / 304.8; if (_section.Category == null) return null; if ((BuiltInCategory)_section.Category.Id.IntegerValue != BuiltInCategory.OST_Viewers) return null; List<Autodesk.Revit.DB.View> _views = new FilteredElementCollector(_section.Document) .OfClass(typeof(Autodesk.Revit.DB.View)) .Cast<Autodesk.Revit.DB.View>() .ToList(); Autodesk.Revit.DB.View _viewFromSection = null; foreach (var v in _views) { if (_section.Name == v.Name && _section.GetTypeId() == v.GetTypeId()) _viewFromSection = v; } if (_viewFromSection == null) return null; ViewFamilyType _vType = _section.Document.GetElement(_section.GetTypeId()) as ViewFamilyType; BoundingBoxXYZ _bb1 = null; using (SubTransaction st1 = new SubTransaction(_section.Document)) { st1.Start(); Parameter par = _vType.get_Parameter(BuiltInParameter.SECTION_TAG); par.Set(ElementId.InvalidElementId); par = _vType.get_Parameter(BuiltInParameter.VIEWER_REFERENCE_LABEL_TEXT); par.Set(string.Empty); _view.Scale = 1; _section.Document.Regenerate(); _bb1 = _section.get_BoundingBox(_view); st1.RollBack(); } BoundingBoxXYZ _ViewBB = _viewFromSection.get_BoundingBox(_viewFromSection); BoundingBoxXYZ _bb = _section.get_BoundingBox(_view); XYZ pt1 = _bb.Min; XYZ pt2 = _bb.Max; if (_bb1 != null) { pt1 = _bb1.Min; pt2 = _bb1.Max; } XYZ Origin = _viewFromSection.Origin; XYZ ViewBasisX = _viewFromSection.RightDirection; XYZ ViewBasisY = _viewFromSection.ViewDirection; if (ViewBasisX.X < 0 ^ ViewBasisX.Y < 0) { double _d = pt1.Y; pt1 = new XYZ(pt1.X, pt2.Y, pt1.Z); pt2 = new XYZ(pt2.X, _d, pt2.Z); } XYZ ToPlane1 = pt1.Add(ViewBasisY.Multiply(ViewBasisY.DotProduct(Origin.Subtract(pt1)))); XYZ ToPlane2 = pt2.Subtract(ViewBasisY.Multiply(ViewBasisY.DotProduct(pt2.Subtract(Origin)))); XYZ _correctionVector = ToPlane2.Subtract(ToPlane1).Normalize().Multiply(_correction); XYZ endPoint0 = ToPlane1.Add(_correctionVector); XYZ endPoint1 = ToPlane2.Subtract(_correctionVector); return Line.CreateBound(endPoint0, endPoint1); }
Beautiful sample!
Especially after the development team said 'no hope' 🙂
Thank you, and congratulations!
Definitive blog post material, if I may...
Cheers,
Jeremy
FAIR59,
Thanks for the response. I have a few questions:
@jeremytammik : feel free to use my contributions for your blog
@Anonymous:
answer 1.
the boundingbox of a sectionline is the result of a number of elements
in the method I "hide" 2 and 3. You can't hide the cycle symbol, so the result is to large. I simply added the resulting line without the correction to the project and measured the surplus length. After checking that it is always the same, I implemented the constant _correction = 21.130014403 / 304.8
answer 2.
I didn't distinguish between section vs. callout markers, I merely presumed you had a section marker. There are 2 ways to test
if (_vType.FamilyName == "Section")
if (_viewFromSection.GetType()== typeof(ViewSection))
callouts are PlanViews or Elevations, as far as I know.
answer 3.
I don't know
answer 4.
i'm afraid that is truly hidden. The Section Head and Tail stay in the same position when flipping the section, but the viewDirection and RightDirection changes.
The most you can get is a line in the View.RightDirection
XYZ _direction = ToPlane2.Subtract(ToPlane1).Normalize(); return _direction.IsAlmostEqualTo(ViewBasisX) ? Line.CreateBound(endPoint0, endPoint1) : Line.CreateBound(endPoint1, endPoint0);
Cool solution, cool answers!
Preserved by The Building Coder for posterity here:
http://thebuildingcoder.typepad.com/blog/2017/03/ttt-to-obtain-section-marker-endpoint.html
Thank you!
Cheers,
Jeremy
Amazing work. I would have just used Section.Line.StartPoint.X. Please, it's a joke...
The question: Where did you come up with the "const double _correction = 21.130014403 / 304.8;" value?
Am I understanding correctly that this value (21.1300 etc.) will be dependant on the size and scale of the section marker circle? If so, a custom one would be a different value, correct? Thanks for posting this very helpful code. Regards, Dale
Can't find what you're looking for? Ask the community or share your knowledge.