Automatically Generate Section Stair Dimensions in Revit Secondary Development
Reference
Conversion of Revit Coordinates and Screen Coordinates
Prerequisite
Record of Issues and Solutions for Generation of Vertical Stair Dimensions in Revit
Style
Content
The linked file above provides a method for converting screen coordinates to project coordinates. The principle is calculated by converting the proportion of the point in the screen and the boundary to the project, but the blogger’s method is only applicable to the XY plane case. If applied to a section, it cannot be satisfied. Sections will have orthogonal sections and parallel XY axis cuts or oblique sections, so the following uses the blogger’s ideas to modify the method.
- First analyze the section view, which can be seen as horizontal and vertical. Vertical only represents the Z value, and horizontal represents the (X, Y) value, but the horizontal plane will have rotation offset. You can think of this as the bamboo-copter turned when you were a child. Secondly, the section view we see in Revit is actually the projection of the oblique section on the screen.
- When we obtain the clicked screen coordinates, we will get the screen’s (X, Y) point, and then obtain the screen Rectangle of the Revit workspace, thereby calculating the proportion of XY in space.
- Here are two situations. Record it. I first wanted to use UV conversion here, but there is a problem. I cannot get the BoundingBoxUV of the View, so forget it.
- Later, I used proportional calculation directly, but it was still the problem of oblique sections. At this time, the two ZoomCorns of the oblique section represent a cube, so it cannot be directly converted by proportion.
- Afterwards, I wanted to convert coordinates through Transform, but we cannot get the converted 3D point because the 2D point of the screen can only provide us with an accurate Z value.
- At this time, because the 3D is reduced to XY plane operation, only consider left or right. Because of Revit’s characteristics, Corns[0] represents the left side, 1 represents the right side. This is when we can connect two points with the same Z value into a vector, and bring the horizontal X proportion into the Vector calculation to obtain the horizontal XY value. Combined, it is an accurate 3D coordinate.
- Through the first three steps plus a transparent window click interface, the function of automatically generating stair dimensions by user selecting vertical dimension position can be realized. This is not complicated to say, just that I got into the solution of matrix operation at the beginning and took a detour.
Coding a modern tutorial, with a clear explanation of matrices. Reading this will give you a deeper understanding of matrix operations.
Linear Algebra Course: The Essence of Linear Algebra
Code
Screen coordinates to Revit coordinates, only applicable to sections, planes can use the blogger above.
1 | /// <summary> |





