Section Plan by 3 points

Good morning, everybody!
I need to create a Section View aligned at a plane. This plane is inclined in every direction.

I could generate the plane section from 3 points by xyz coordinates. But in Dynamo I don’t finding an helpful script.

Thank you in advance.

I don’t believe that is possible in Revit. The only creation method for sections i know is using a bounding box which will always sit on the XY plane.

Keen to hear from others if it is though…

1 Like

The Revit API allows transformations on bounding boxes.

As such you can do stuff like this: The Building Coder: Create Section View Parallel to Wall

1 Like

I’m sorry, but from these script it seems impossible to rotate the view around the x or y axis… My object has inclinations in every direction

The code sample on the building coder site (2nd link) uses the global Z axis for ‘up’ which isn’t what you would want to use.

XYZ up = XYZ.BasisZ;

It’s in C so not a direct transition to something which can be used in Dynamo, but give the translation a shot.

1 Like

An example with 1 point on Face (to adapt if necessary)

import clr
import sys
import System
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *

from System.Collections.Generic import List

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application

viewFamilyType = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements().Find(lambda x : x.ViewFamily == ViewFamily.Section)
v = None
TaskDialog.Show("Selection", "Select Point on Face")
ref = uidoc.Selection.PickObject(ObjectType.Face, "Select Point on Face")
elem = doc.GetElement(ref)
face = elem.GetGeometryObjectFromReference(ref)
midpoint = ref.GlobalPoint
bbxUV = face.GetBoundingBox()
faceNormal = face.ComputeNormal((bbxUV.Min + bbxUV.Max) * 0.5).Negate()
bbxElem = elem.get_BoundingBox(None)
midX = (bbxElem.Max.X - bbxElem.Min.X) * 0.5
midY = (bbxElem.Max.Y - bbxElem.Min.Y) * 0.5
zV = faceNormal
xV = XYZ.BasisZ.CrossProduct(faceNormal).Normalize()
yV = zV.CrossProduct(xV).Normalize()
t = Transform.Identity
t.Origin = midpoint
t.BasisX = xV
t.BasisY = yV
t.BasisZ = zV

sectionBox = BoundingBoxXYZ()
sectionBox.Enabled = True
sectionBox.Min =  XYZ(-midX, -midY, -3)
sectionBox.Max =  XYZ(midX, midY, 1)
sectionBox.Transform = t

v = DB.ViewSection.CreateSection(doc, viewFamilyType.Id, sectionBox)

OUT = face, midpoint.ToPoint(), faceNormal, v

Remarks from Revit API Doc

Create a section whose view volume corresponds geometrically with the specified sectionBox. The view direction of the resulting section will be sectionBox.Transform.BasisZ and the up direction will be sectionBox.Transform.BasisY. The right hand direction will be computed so that (right, up, view direction) form a left handed coordinate system. The resulting view will be cropped, and far clipping will be active. The crop region will correspond to the projections of BoundingBoxXYZ.Min and BoundingBoxXYZ.Max onto the view’s cut plane. The far clip distance will be equal to the difference of the z-coordinates of BoundingBoxXYZ.Min and BoundingBoxXYZ.Max. The new section ViewSection will receive a unique view name.