1. 程式人生 > >revit 二次開發 如何修改元素的表面顏色

revit 二次開發 如何修改元素的表面顏色

1、獲取填充圖案

 FilteredElementCollector fillPatternElementFilter = new FilteredElementCollector(doc);
                fillPatternElementFilter.OfClass(typeof(FillPatternElement));
                //獲取實體填充
                FillPatternElement fillPatternElement = fillPatternElementFilter.First(f => (f as FillPatternElement).GetFillPattern().IsSolidFill) as FillPatternElement;

2、修改圖元的填充圖案與顏色並應用於當前檢視  312116是某個元素的id
OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
                overrideGraphicSettings = doc.ActiveView.GetElementOverrides(new ElementId(312116));
                overrideGraphicSettings.SetProjectionFillPatternId(fillPatternElement.Id);
                overrideGraphicSettings.SetProjectionFillColor(new Autodesk.Revit.DB.Color(255, 255, 0));
                doc.ActiveView.SetElementOverrides(new ElementId(312116), overrideGraphicSettings);