2027 Class
Changes 0
C

TessellatedShapeBuilder

Description:
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.
Remarks:
Creates a geometry populated with faces defined by TessellatedFace objects stored in the input connected face sets. The faces defined by each connected face set may form an open shell or the boundary of a solid 3D region. All faces are planar and have polyline boundaries, defined as sequences of 3d coordinates. Faces are added to the builder as a part of connected face sets, representing faces which share edges. Order of faces in the sets is irrelevant. Faces can only be added to the builder when a face set has been opened and is available to take in faces (use OpenConnectedFaceSet(Boolean) to open a new 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. The builder will try to create a geometry valid in Revit despite inconsistencies or omissions in the input data.
  • For each connected face set, it will check the face orientations and change them wherever needed so that the orientations of the faces in that set are consistent.
  • If a connected face set is closed, it will check if the face normals point outward. If not, it will reverse the orientations of all faces. That means, each closed connected face set will represent a solid.
Limitations in the current implementation:
  • It does not support the definition of a "void", even if the user had set the orientations of the faces to define a "void".
  • If there is more than one connected face set, it does not check if they intersect or overlap each other.
Inheritance Hierarchy:
System.Object
  Autodesk.Revit.DB.ShapeBuilder
    Autodesk.Revit.DB.TessellatedShapeBuilder
// 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();
    }
}
Name Return Type Description Inherited From
C TessellatedShapeBuilder() None Constructs a new instance of a TessellatedShapeBuilder.
Name Return Type Description Inherited From
M AddFace(TessellatedFace) None Adds a face to the currently open connected face set.
M AreTargetAndFallbackCompatible(TessellatedShapeBuilderTarget, TessellatedShapeBuilderFallback) Boolean Checks whether this combination of fallback and target parameters can be used as a valid combination of inputs.
M Build() None Builds the designated geometrical objects from the stored face sets. Stores the result in this TessellatedShapeBuilder object.
M CancelConnectedFaceSet() None Cancels the current face set - i.e., all data from it will be lost and the builder will have no open connected face set anymore.
M Clear() None Erases all face set and clears the logs, if any.
M CloseConnectedFaceSet() None Closes the currently open connected face set.
M CreateMeshByExtrusion(IList<CurveLoop>, XYZ, Double, ElementId) MeshFromGeometryOperationResult Builds a mesh by extruding curve loop(s) along extrusion distance.
M Dispose() None (Inherited from ShapeBuilder ) ShapeBuilder
M DoesFaceHaveEnoughLoopsAndVertices(TessellatedFace) Boolean Checks whether 'face' has enough loops and vertcies to be valid.
M Equals None Determines whether the specified object is equal to the current object. (Inherited from Object ) Object
M GetBuildResult() TessellatedShapeBuilderResult Get the built geometry, build status and other data stored in TessellatedShapeBuilderResult. Clears the stored data.
M GetHashCode None Serves as the default hash function. (Inherited from Object ) Object
M GetType None Gets the Type of the current instance. (Inherited from Object ) Object
M OpenConnectedFaceSet(Boolean) None Opens a new connected face set.
M ToString None Returns a string that represents the current object. (Inherited from Object ) Object
Name Return Type Description Inherited From
P Fallback TessellatedShapeBuilderFallback Defines acceptable fallback if the desired type of geometry can't be built.
P GraphicsStyleId ElementId Optional - if set, the built geometry will use that graphics style.
P IsFaceSetOpen bool Flag whether the current set of connected faces is open and additional tessellation faces can be added to it.
P IsValidObject Boolean Specifies whether the .NET object represents a valid Revit entity. (Inherited from ShapeBuilder ) ShapeBuilder
P LogInteger int Integer value used for logging, if it is performed. Usually the number of the face set(s) in the IFC file, from which they are imported. Any value is acceptable.
P LogString string String used for logging, if any. Usually the name of the file from which face sets were imported.
P NumberOfCompletedFaceSets int Number of completed face sets.
P OwnerInfo string String used for logging, if any. Usually describes the element or object, which either defined or will own the geoemtrical objects to be built.
P Target TessellatedShapeBuilderTarget Requests the type of geometry to be built.