Visualizing Faces with AVF

Visualizing Faces with AVF

Anonymous
Not applicable
527 Views
1 Reply
Message 1 of 2

Visualizing Faces with AVF

Anonymous
Not applicable

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.

 

 

0 Likes
528 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

If you don't know what face it is how do you know it is visible in the view i.e. a requirement noted in the AVF error message? I believe you also need to have some results to display using AVF.

 

I would be inclined to try something a bit more basic such as drawing model lines across corners of face or tracing over the edges of the face with model lines. You could also draw a line from face origin along the face normal direction to identify it.

0 Likes