Spatial |
Exception | Condition |
---|---|
ArgumentNullException | A non-optional argument was null |
ArgumentOutOfRangeException | trf is not conformal. |
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.
// Create SpatialFieldPrimitive to display results offset from a face BoundingBoxUV bb = face.GetBoundingBox(); UV min = bb.Min; UV max = bb.Max; // Find the face normal at the center of the face's bounding box UV 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.5 XYZ faceCenterNormalMultiplied = faceCenterNormal.Normalize().Multiply(2.5); Transform transform = Transform.CreateTranslation(faceCenterNormalMultiplied); // Use face and transform when adding the SpatialFieldPrimitive SpatialFieldManager sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 3); int idx = sfm.AddSpatialFieldPrimitive(face, transform);