【Revit API】改变填充区域的填充样式
程序员文章站
2022-03-31 22:56:49
话不多说,直接上代码 ......
话不多说,直接上代码
var target = pattern.Target; var name = pattern.Name; var fpElem = FillPatternElement.GetFillPatternElementByName(doc, target, name); using (var tran = new Transaction(doc, "FillPattern")) {
tran.Start(); var selectionIds = app.ActiveUIDocument.Selection.GetElementIds(); if (selectionIds != null && selectionIds.Any()) { foreach (var id in selectionIds) { FilledRegion elem = doc.GetElement(id) as FilledRegion; if (elem != null && !elem.IsMasking) { OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings(); overrideGraphicSettings = doc.ActiveView.GetElementOverrides(elem.Id); overrideGraphicSettings.SetProjectionFillPatternId(fpElem.Id); doc.ActiveView.SetElementOverrides(elem.Id, overrideGraphicSettings); } } } tran.Commit();
}
下一篇: Redis学习笔记(二)