RevitNet calls the ray method in the Revit API to find the problem record of two different values in the same component of the model.

Ray method intersection is the most commonly used node for collision and distance measurement in many three-dimensional models. However, when you use the ray method to set it targetto element, you will find that two identical values ​​will appear.
The floor distance is used below. Two different values ​​will appear in the picture below. After I modified the plate thickness, I found that it is exactly the distance between the plate thickness. It can be guessed that the ray method will determine the intersection of the two faces, but with each of the faces we need The element outputs a value that does not match. You need to make a new judgment here or directly take the minimum value to obtain the net height.

var intersector = new ReferenceIntersector(classFilter, FindReferenceTarget.Element, modelView);
                intersector.FindReferencesInRevitLinks = true;

                var result = intersector.Find(origin, -XYZ.BasisZ);

                foreach (var context in result)
                {
                    var ele = context.GetReference();
                    var revitLinkInstance = _document.GetElement(ele) as RevitLinkInstance;
                    var linkDoc = revitLinkInstance.GetLinkDocument();
                    
                    var eleName = linkDoc.GetElement(ele.LinkedElementId);
                    
                    var eleNmae = _document.GetElement(ele).Name;
            
                    
                    MessageBox.Show(result.Count.ToString() + "-" + eleNmae + $"{eleName.GetType()}" + "-" + context.Proximity * 304.8);
                }

Insert image description here
Insert image description here
Later, I changed the method to get the nearest face to avoid this situation, but in other cases, you may need to cycle through the contextvalues ​​and re-screen.


            var result = intersector.FindNearest(origin, -XYZ.BasisZ);


            var stringbuild = new StringBuilder();

            var ele = result.GetReference();
            var revitLinkInstance = _document.GetElement(ele) as RevitLinkInstance;
            var linkDoc = revitLinkInstance?.GetLinkDocument();

            var eleName = linkDoc?.GetElement(ele.LinkedElementId);

            stringbuild.Append(
                $"ElementType : {eleName?.GetType()} , ElementLinkId:{ele.LinkedElementId} ,Proximity : {result.Proximity * 304.8} \r\n");

            MessageBox.Show(stringbuild.ToString());

Guess you like

Origin blog.csdn.net/qq_41059339/article/details/131248237