Namespace:
Autodesk.Revit.DB.Analysis
SpatialFieldManager
Class
Description:
Exposes all API for an external analysis application. Its primary role is creation, deletion and modification of SpatialFieldElement elements.
Exposes all API for an external analysis application. Its primary role is creation, deletion and modification of SpatialFieldElement elements.
Inheritance Hierarchy:
System.Object
Autodesk.Revit.DB.Element
Autodesk.Revit.DB.Analysis.SpatialFieldManager
System.Object
Autodesk.Revit.DB.Element
Autodesk.Revit.DB.Analysis.SpatialFieldManager
Examples
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);