A class that permits structured building of geometry or
a mesh from a collection of connected faces.
Contains all closed face sets and custom precisions.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since:
2015
Syntax
C# |
---|
public class TessellatedShapeBuilder : ShapeBuilder |
Visual Basic |
---|
Public Class TessellatedShapeBuilder _ Inherits ShapeBuilder |
Visual C++ |
---|
public ref class TessellatedShapeBuilder : public ShapeBuilder |
Remarks
Creates a geometry populated with a shell or a connected solid (a
solid may have inner voids) from the sets of connected faces.
All faces are planar and have polyline boundaries, defined
as sequences of 3d coordinates.
Faces are added to the builder as a part of face sets,
representing faces which share edges
(e.g., outer 'surface' of a solid or inner 'surface'
of solid voids). Order of faces in sets is irrelevant. Faces can only
be added to the build while a face set is "open" (use
OpenConnectedFaceSet(Boolean) to open a face set).
Before attempting to build Revit geometry from the builder
the current face set should be closed
(CloseConnectedFaceSet()()()()).
The builder allows for the possibility of multiple face
sets - in such cases the first set should represent the
outer 'surface' of a body and all following sets
represent interior voids.
The builder tries to create a geometry valid in Revit despite
inconsistencies or omissions in the input data.
Examples

// Create a pyramid-shaped DirectShape using given material for the faces public void CreateTessellatedShape(Document doc, ElementId materialId) { List<XYZ> loopVertices = new List<XYZ>(4); TessellatedShapeBuilder builder = new TessellatedShapeBuilder(); builder.OpenConnectedFaceSet(true); // create a pyramid with a square base 4' x 4' and 5' high double length = 4.0; double height = 5.0; XYZ basePt1 = XYZ.Zero; XYZ basePt2 = new XYZ(length, 0, 0); XYZ basePt3 = new XYZ(length, length, 0); XYZ basePt4 = new XYZ(0, length, 0); XYZ apex = new XYZ(length / 2, length / 2, height); loopVertices.Add(basePt1); loopVertices.Add(basePt2); loopVertices.Add(basePt3); loopVertices.Add(basePt4); builder.AddFace(new TessellatedFace(loopVertices, materialId)); loopVertices.Clear(); loopVertices.Add(basePt1); loopVertices.Add(apex); loopVertices.Add(basePt2); builder.AddFace(new TessellatedFace(loopVertices, materialId)); loopVertices.Clear(); loopVertices.Add(basePt2); loopVertices.Add(apex); loopVertices.Add(basePt3); builder.AddFace(new TessellatedFace(loopVertices, materialId)); loopVertices.Clear(); loopVertices.Add(basePt3); loopVertices.Add(apex); loopVertices.Add(basePt4); builder.AddFace(new TessellatedFace(loopVertices, materialId)); loopVertices.Clear(); loopVertices.Add(basePt4); loopVertices.Add(apex); loopVertices.Add(basePt1); builder.AddFace(new TessellatedFace(loopVertices, materialId)); builder.CloseConnectedFaceSet(); builder.Target = TessellatedShapeBuilderTarget.Solid; builder.Fallback = TessellatedShapeBuilderFallback.Abort; builder.Build(); TessellatedShapeBuilderResult result = builder.GetBuildResult(); using (Transaction t = new Transaction(doc, "Create tessellated direct shape")) { t.Start(); DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel)); ds.ApplicationId = "Application id"; ds.ApplicationDataId = "Geometry object id"; ds.SetShape(result.GetGeometricalObjects()); t.Commit(); } }

' Create a pyramid-shaped DirectShape using given material for the faces Public Sub CreateTessellatedShape(doc As Document, materialId As ElementId) Dim loopVertices As New List(Of XYZ)(4) Dim builder As New TessellatedShapeBuilder() builder.OpenConnectedFaceSet(True) ' create a pyramid with a square base 4' x 4' and 5' high Dim length As Double = 4.0 Dim height As Double = 5.0 Dim basePt1 As XYZ = XYZ.Zero Dim basePt2 As New XYZ(length, 0, 0) Dim basePt3 As New XYZ(length, length, 0) Dim basePt4 As New XYZ(0, length, 0) Dim apex As New XYZ(length / 2, length / 2, height) loopVertices.Add(basePt1) loopVertices.Add(basePt2) loopVertices.Add(basePt3) loopVertices.Add(basePt4) builder.AddFace(New TessellatedFace(loopVertices, materialId)) loopVertices.Clear() loopVertices.Add(basePt1) loopVertices.Add(apex) loopVertices.Add(basePt2) builder.AddFace(New TessellatedFace(loopVertices, materialId)) loopVertices.Clear() loopVertices.Add(basePt2) loopVertices.Add(apex) loopVertices.Add(basePt3) builder.AddFace(New TessellatedFace(loopVertices, materialId)) loopVertices.Clear() loopVertices.Add(basePt3) loopVertices.Add(apex) loopVertices.Add(basePt4) builder.AddFace(New TessellatedFace(loopVertices, materialId)) loopVertices.Clear() loopVertices.Add(basePt4) loopVertices.Add(apex) loopVertices.Add(basePt1) builder.AddFace(New TessellatedFace(loopVertices, materialId)) builder.CloseConnectedFaceSet() builder.Target = TessellatedShapeBuilderTarget.Solid builder.Fallback = TessellatedShapeBuilderFallback.Abort builder.Build() Dim result As TessellatedShapeBuilderResult = builder.GetBuildResult() Using t As New Transaction(doc, "Create tessellated direct shape") t.Start() Dim ds As DirectShape = DirectShape.CreateElement(doc, New ElementId(BuiltInCategory.OST_GenericModel)) ds.ApplicationId = "Application id" ds.ApplicationDataId = "Geometry object id" ds.SetShape(result.GetGeometricalObjects()) t.Commit() End Using End Sub
Inheritance Hierarchy
System..::..Object
Autodesk.Revit.DB..::..ShapeBuilder
Autodesk.Revit.DB..::..TessellatedShapeBuilder
Autodesk.Revit.DB..::..ShapeBuilder
Autodesk.Revit.DB..::..TessellatedShapeBuilder