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.0.0 (17.0.484.0)
Since:
2011
Syntax
Examples
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>();
doubleList.Add(0);
valList.Add(new ValueAtPoint(doubleList));
doubleList.Clear();
doubleList.Add(10);
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);
Copy
VB.NET
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)()
doubleList.Add(0)
valList.Add(New ValueAtPoint(doubleList))
doubleList.Clear()
doubleList.Add(10)
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)