欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

【Revit API】改变填充区域的填充样式

程序员文章站 2022-08-06 08:46:55
话不多说,直接上代码 ......

话不多说,直接上代码

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();
}