Reference of Face is null with Revit 2018

Reference of Face is null with Revit 2018

tubagezll
Explorer Explorer
1,429 Views
2 Replies
Message 1 of 3

Reference of Face is null with Revit 2018

tubagezll
Explorer
Explorer

I try to get all faces of element, it works well with Revit 2106, but some faces have no reference with Revit 2018.

The code is something like below:

 

Options geOpt = new Options();
geOpt.ComputeReferences = true; // ensure we calculate the reference so that we can reserve the persistent representation string
Dictionary<Face, Solid> faceAndSolidDict1 = new Dictionary<Face, Solid>();
List<Solid> solids1 = GetElementSolids(elem1, geOpt); //a method to get element's solids
// add all faces into a list foreach (Solid solid in solids1) { foreach (Face face in solid.Faces) { faceAndSolidDict1.Add(face, solid); if (null != element1Faces) { element1Faces.Add(face); } } }

 

I find that Face.reference is null when Face.OrientationMatchesSurfaceOrientation is false.

TIM图片20180412114104.png

Thanks

0 Likes
1,430 Views
2 Replies
Replies (2)
Message 2 of 3

tubagezll
Explorer
Explorer

with Revit 2016, same face has reference.

revit2016.png

0 Likes
Message 3 of 3

so-chong
Advocate
Advocate

 Hi,

The Face.OrientationMatchesSurfaceOrientation property identify whether the face's orientation matches the surface orientation.
If true, the reference returns a value.
If false, the reference returns null.
This property was introduced in Revit 2018, in Revit 2016 this property did not exist and that is why i think your code works in 2016 and not in 2018.
Or at least only returns(if true) faces with values in 2018.
Try use Face.GetSurface() method in 2018.
i hope this clarifies and assume what your problem was.