SpatialFieldManager Class

Exposes all API for an external analysis application. Its primary role is creation, deletion and modification of SpatialFieldElement elements.

Namespace: Autodesk.Revit.DB.Analysis
Assembly: RevitAPI (in RevitAPI.dll) Version: (17.0.484.0)
Since: 2011


public class SpatialFieldManager : Element
Visual Basic
Public Class SpatialFieldManager _
	Inherits Element
Visual C++
public ref class SpatialFieldManager : public Element


Copy C#
Document doc = commandData.Application.ActiveUIDocument.Document;
UIDocument uiDoc = commandData.Application.ActiveUIDocument;

SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView);
if (null == sfm)
    sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1);
Reference reference = uiDoc.Selection.PickObject(ObjectType.Face, "Select a face");
int idx = sfm.AddSpatialFieldPrimitive(reference);

Face face = doc.GetElement(reference).GetGeometryObjectFromReference(reference) as Face;

IList<UV> uvPts = new List<UV>();
BoundingBoxUV bb = face.GetBoundingBox();
UV min = bb.Min;
UV max = bb.Max;
uvPts.Add(new UV(min.U,min.V));
uvPts.Add(new UV(max.U,max.V));

FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts);

List<double> doubleList = new List<double>();
IList<ValueAtPoint> valList = new List<ValueAtPoint>();
valList.Add(new ValueAtPoint(doubleList));
valList.Add(new ValueAtPoint(doubleList));

FieldValues vals = new FieldValues(valList);
AnalysisResultSchema resultSchema = new AnalysisResultSchema("Schema Name", "Description");
int schemaIndex = sfm.RegisterResult(resultSchema);
sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, schemaIndex);
Dim doc As Document = commandData.Application.ActiveUIDocument.Document
Dim uiDoc As UIDocument = commandData.Application.ActiveUIDocument

Dim sfm As SpatialFieldManager = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView)
If sfm Is Nothing Then
   sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1)
End If
Dim reference As Reference = uiDoc.Selection.PickObject(ObjectType.Face, "Select a face")
Dim idx As Integer = sfm.AddSpatialFieldPrimitive(reference)

Dim face As Face = TryCast(doc.GetElement(reference).GetGeometryObjectFromReference(reference), Face)

Dim uvPts As IList(Of UV) = New List(Of UV)()
Dim bb As BoundingBoxUV = face.GetBoundingBox()
Dim min As UV = bb.Min
Dim max As UV = bb.Max
uvPts.Add(New UV(min.U, min.V))
uvPts.Add(New UV(max.U, max.V))

Dim pnts As New FieldDomainPointsByUV(uvPts)

Dim doubleList As New List(Of Double)()
Dim valList As IList(Of ValueAtPoint) = New List(Of ValueAtPoint)()
valList.Add(New ValueAtPoint(doubleList))
valList.Add(New ValueAtPoint(doubleList))

Dim vals As New FieldValues(valList)
Dim resultSchema As New AnalysisResultSchema("Schema Name", "Description")
Dim schemaIndex As Integer = sfm.RegisterResult(resultSchema)
sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, schemaIndex)

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB.Analysis SpatialFieldManager

See Also