Parts

Parts

Parts can be generated from elements with layered structures, such as:

In the Revit API, elements can be divided into parts using the PartUtils class. The static method PartUtils.CreateParts() is used to create parts from one or more elements. Note that unlike most element creation methods in the API, CreateParts() does not actually create or return the parts, but rather instantiates an element called a PartMaker. The PartMaker uses its embedded rules to drive creation of the needed parts during regeneration.

The API also offers an interface to subdivide parts. PartUtils.DivideParts() accepts as input a collection of part ids, a collection of “intersecting element” ids (which can be layers and grids), and a collection of curves. The routine uses the intersecting elements and curves as boundaries from which to divide and generate new parts.

The GetAssociatedParts() method can be called to find some or all of the parts associated with an element, or use HasAssociatedParts() to determine if an element has parts.

You can delete parts through the API either by deleting the individual part elements, or by deleting the PartMaker associated to the parts (which will delete all parts generated by this PartMaker after the next regeneration).

Parts can be manipulated in the Revit API much the same as they can in the Revit user interface. For example, the outer boundaries of parts may be offset with PartUtils.SetFaceOffset().

The following example offsets all the faces of a part that can be offset.

Code Region: Offset Faces of a Part

Part part = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as Part;
Autodesk.Revit.DB.GeometryElement geomElem = part.get_Geometry(newOptions());

foreach(GeometryObject geomObject in geomElem)
{
    if (geomObjectisSolid)
    {
        Solidsolid = geomObject as Solid;
        FaceArray faceArray = solid.Faces;
        foreach (FacefaceinfaceArray)
        {
            if (part.CanOffsetFace(face))
            {
                part.SetFaceOffset(face, 1);
            }
        }
    }
} 

Before and After Offseting faces of a selected Part