简体   繁体   中英

How can I flip a live section with the Revit API

I would like to be able to flip a live section using the Revit 2017 API. It would be the equivalent of the UI feature seen in my images below.

之前 后

I've tried using the built-in ElementTransformUtils.MirrorElement but that will only create a second section marker with a second section view. Is there any way that I can achieve this using the Revit API?

I got a solution to my post How can I flip a section using the Revit 2017 API on the Revit API forum. It turns out that I overlooked the plural ElementTransformUtils.MirrorElements function which I assumed was almost exactly the same as the singular ElementTransformUtils.MirrorElement except for doing multiple element mirrors instead of a single mirror. The plural ElementTransformUtils.MirrorElements has a bool mirrorCopies parameter that you can set to false which will force the original section to be mirrored instead of just making mirrored copy of the original. Here are the two function signatures side-by-side:

void MirrorElement(
  Document document, 
  ElementId elementToMirror, 
  Plane plane
);

IList<ElementId> MirrorElements(
  Document document, 
  ICollection<ElementId> elementsToMirror, 
  Plane plane, 
  bool mirrorCopies
);

My code ends up looking like this (with elementsToMirror only containing a single element):

ElementTransformUtils.MirrorElements(document, elementsToMirror, mirrorPlane, false);

You need to change the CropBox property of the ViewSection object. The Z components of the Min and Max properties should be inverted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM