Section line location
Drawing a section over a plan drawing is crucial for getting a better view of how an element is positioned or constructed. For instance, we can easily observe and manage a wall's height through a section.
Assuming we already have a section view and need to draw the section line that shows its position on a plan, this is achievable using the Revit API, albeit with some limitations.
Let's begin with what the Revit API can offer. Firstly, we obtain the crop box of the section view sectionView.CropBox
, then we acquire its Transform
. This transform enables us to convert the bounding box corner points to world space coordinates. Through trial and error, I discovered that the maximum point of the Section view is the one located above the section line, while the minimum point indicates the depth of the section. Refer to the snapshot below illustrating a 3D Bounding box extracted from the section View.
Since we already have the maximum point from the crop box, which is the Top Right corner, we can easily determine the Top Left corner. By using these two points, we can draw a line over the plan view. Refer to the code below to see how this works.
var cropBox = sectionView.CropBox;
var topRight = cropBox.Max;
var topLeft = new XYZ(cropBox.Min.X, cropBox.Max.Y, cropBox.Max.Z);
topRight = cropBox.Transform.OfPoint(topRight);
topLeft = cropBox.Transform.OfPoint(topLeft);
var line = Line.CreateBound(topRight, topLeft);
// a transaction must be opened here
planView.Document.Create.NewDetailCurve(planView, line);
// commit transaction
Limitations
The method only represents the bounding box of the section view and does not consider the actual segment of the section line.
If the section line is segmented or cut to show different depths, this will be disregarded.
If the bounding box changes from the section line, the drawn line will align with the section view.
As of the date of publishing this article, access to the section line segments and the bubble is still limited in the Revit API. Fortunately, this is already a requested feature on Revit Autodesk Ideas.
Subscribe to my newsletter
Read articles from Moustafa Khalil directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Moustafa Khalil
Moustafa Khalil
I'm Moustafa Khalil El-Sayed, an Egyptian native with a passion for architecture and technology. After completing high school in 1999, I embarked on my journey into architecture, earning my Bachelor's degree in Architecture in 2004. My academic pursuits continued, and I later acquired my Master's degree in Architecture from Wings University. However, my thirst for knowledge extended beyond architectural design, leading me to pursue a degree in Computer Science as well. Driven by a desire to innovate, I began self-teaching computer science, which later empowered me to achieve my Associate degree in Computer Science from the University of the People more easily. Armed with dual expertise in architecture and computer science, I've cultivated a unique skill set that blends creativity with technical acumen. My career has taken me across borders, from Egypt to Oman and the UAE, where I've honed my skills as an architect. As a graduate architect and a proficient .NET BIM Solution Developer, I specialize in translating unique visions into tangible realities. My role extends beyond conventional architectural practices; I leverage technology to streamline processes and enhance project outcomes. My journey into programming began with developing script-based Excel tools to augment project management efforts, notably during the Sharm El Sheikh development. Over time, I expanded my programming prowess to address practical challenges encountered in bridging Revit and AutoCAD within my professional sphere. Several of my applications, born from this evolution, have gained recognition, with some even being featured on the Autodesk website. I am committed to pushing boundaries and continually enriching the intersection of architecture and technology, ensuring that my clients benefit from cutting-edge solutions tailored to their needs.