Visualizing Faces with AVF

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
This is a follow-on from my previous post: https://forums.autodesk.com/t5/revit-api-forum/get-bottom-face-of-door/td-p/10379909
I have been able to implement an algorithm to select the (what I think is) correct face of the door, however, I think something is wrong and I want to visually confirm that this is a correct face. I realised that I can use AVF to do this, which is where I run into a problem:
When I try to add a SpatialFieldPrimitive through a reference I get an exception saying:
"must point to either Face or Curve visible in the view
Parameter name: reference"
I have searched through the forums and have tried the following solutions:
- Enabling ComputeReferences
- Using Symbol geometry instead of Instance geometry
- Changing the active view to View3D (the command needs to be run in a plan view since it requires selecting rooms)
However, none of these have worked and I am still getting the error.
Does anyone have any other ideas of how I could make this work?
P.S. Code for Creating SpatialFieldPrimitives:
public void displayFaces(List<Face> faces)
{
var sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView);
if(sfm == null)
{
sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1);
}
double step = 1 / faces.Count();
for(int i = 0; i < faces.Count(); ++i)
{
int idx = sfm.AddSpatialFieldPrimitive(faces[i].Reference);
var pnts = new FieldDomainPointsByUV(new List<UV> { new UV(0.5, 0.5) });
var vals = new FieldValues(new List<ValueAtPoint> { new ValueAtPoint(new List<double> {i*step }) });
sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, sfm.RegisterResult(new AnalysisResultSchema("Face Visualisation", "Visualise Faces")));
}
}
The input List<Faces> gets a list of faces that have been extracted from a Family Instance of a door.