revit二次开发构件上色
首先给构件族创建一个材质参数,然后让族的材质使用该参数,即可直接用参数化的过程改变材质
创建某颜色的材质
class MaterialColor { public Material materialTest;
public Document document; public MaterialColor(Document document) => this.document = documentpublic void AddColor() { Transaction transaction = new Transaction(document); transaction.Start("改变颜色"); materialTest = document.GetElement(Material.Create(document, "测试材质")) as Material; //创建材质 materialTest.Color = new Color(255, 255, 0); //更改颜色 transaction.Commit(); } }
然后直接将创建的新的Material赋予参数即可