当前位置:网站首页>Revit secondary development - Hide occlusion elements

Revit secondary development - Hide occlusion elements

2022-07-07 22:22:00 Hey, hey, hey, hey, hey

background : After the conflict detection is completed, you need to display the elements that collide with each other and take screenshots , Because there will be a house 、 Ground and other large models , Therefore, we often encounter elements that are blocked .

Solutions :

1、 Will project's “ Visual style ” Change it to “ Hidden line ” Pattern ( When the screenshot is selected, it will be more clearly displayed )、 Set the view direction to top ( From the top down ).

2、 Create a model line to detect which occlusion elements , And hide the element .

3、 After the screenshot, show the hidden elements .

// Set the visual style of the project 
uiDoc.ActiveView.get_Parameter(BuiltInParameter.MODEL_GRAPHICS).Set(2);
// Set the view to top 
View3D view = uiDoc.ActiveView as View3D;
view.OrientTo(-XYZ.BasisZ);

// Create a model line according to the midpoint of the element , Filter out occluding elements 
XYZ ptStart = null;
if(element.Location is LocationPoint)
{
    LocationPoint lp = element.Location as LocationPoint;
    ptStart = lp.Point;
}
else if(element.Location is LocationCurve)
{
    LocationCurve lc = element.Location as LocationCurve;
    ptStart = (lc.Curve.GetEndPoint(0) + lc.Curve.GetEndPoint(1)) / 2;
}
else
{
    BoundingBoxXYZ box = element.get_BoundingBox(doc.ActiveView);
    ptStart = (box.Min + box.Max) / 2;
}
XYZ ptEnd = new XYZ(ptStart.X,ptStart.Y,ptStart.Z + 100);
ModelCurve mc = DrawModelCurve(doc,Line.CreateBound(ptStart,ptEnd));
BoundingBoxXYZ mcBox = mc.get_BoundingBoxXYZ(doc.ActiveView);
Outline ol = new Outline(mcBox.Min,mcBox.Max);
BoundingBoxIntersectsFilter boxFilter = new BoundingBoxIntersectsFilter(ol);
FilteredElementCollector fec = new FilteredElementCollector(doc);
List<ElementId> ids = fec.WherePasses(boxFilter).ToElementIds().ToList();

// Set the occlusion element to hide 
uiDoc.ActiveView.HideElements(ids);

// Screenshot 
ImageExportOptions ieo = new ImageExportOptions();
ieo.ZoomType = ZoomType.FitToPage;
iep.ExportRange = ExportRange.VisibleRegionOfCurrentView;
ieo.FilePath = @"d:\";
ieo.GLRandWFViewsFileType = ImageFileType.JPEGMedium;
ieo.ShadowViewsFileType =  ImageFileType.JPEGMedium;
doc.ExportImage(ieo);
// Show occluded elements 
uiDoc.ActiveView.UnhideElements(ids);

DrawModelCurve

原网站

版权声明
本文为[Hey, hey, hey, hey, hey]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130606206975.html