SpatialFieldManager.AddSpatialFieldPrimitive(Face, Transform)
Creates empty analysis results primitive associated with a face and a transform.
Namespace: Autodesk.Revit.DB.Analysis
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public int AddSpatialFieldPrimitive( Face face, Transform trf)
Parameters
face Face
Face to be associated with the primitive
trf Transform
Conformal Transform to be applied to %face%
Return Value
Int32
Unique index of primitive for future references
Exceptions
Exception
Condition
ArgumentNullException
A non-optional argument was null
ArgumentOutOfRangeException
trf is not conformal.
Remarks
This method accepts a reference to a model face, and a transform to be applied to that face, allowing the display of analytical results on faces which are not strictly a part of the Revit model.
This method should not be used if the transform is the identity transform, i.e. the intent is to display results on a face which is part of the Revit model. In that case, use the overload of this method which accepts a reference.
If the input face is from the geometry of a symbol, the face will be considered to be in the location specified by its symbol geometry. If your intention is to transform the face relative to its location in the instance, your input transform must consist of the instance’s transform left multiplied by the extra transform to get the results you expect.
Example
// Create SpatialFieldPrimitive to display results offset from a faceBoundingBoxUV bb = face.GetBoundingBox();UV min = bb.Min;UV max = bb.Max;
// Find the face normal at the center of the face's bounding boxUV faceCenter = new UV((max.U + min.U) / 2, (max.V + min.V) / 2);Transform computeDerivatives = face.ComputeDerivatives(faceCenter);XYZ faceCenterNormal = computeDerivatives.BasisZ;
// Normalize the normal vector and multiply by 2.5XYZ faceCenterNormalMultiplied = faceCenterNormal.Normalize().Multiply(2.5);Transform transform = Transform.CreateTranslation(faceCenterNormalMultiplied);
// Use face and transform when adding the SpatialFieldPrimitiveSpatialFieldManager sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 3);int idx = sfm.AddSpatialFieldPrimitive(face, transform);