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.
JC

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.

https://www.revitapidocs.com/2022/d6228f68-3643-8aaf-72bb-f9a0b4125886.htm

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)
createSection

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *

from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
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

TransactionManager.Instance.EnsureInTransaction(doc)
v = DB.ViewSection.CreateSection(doc, viewFamilyType.Id, sectionBox)
TransactionManager.Instance.TransactionTaskDone()

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.
https://www.revitapidocs.com/2022/d6228f68-3643-8aaf-72bb-f9a0b4125886.htm

7 Likes