您的位置:首页 > 其它

Revit 二次开发 修改对象的颜色

2014-05-19 14:59 351 查看
//修改对象颜色

[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class ChangeColor : IExternalCommand
{

public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
ChangeElementColor(commandData, elements);
return Result.Succeeded;
}

public void ChangeElementColor(ExternalCommandData   commandData, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;

ElementId el = new ElementId(729401);

Transaction trans = new Transaction(doc);
trans.Start("ChangeColor");

Color color = new Color((byte)255, (byte)0, (byte)0);
OverrideGraphicSettings ogs = new OverrideGraphicSettings();
//设置ElementId为729401的Element的颜色
ogs.SetProjectionLineColor(color);//投影表面线的颜色
ogs.SetCutFillColor(color);//切割面填充颜色
Autodesk.Revit.DB.View view = doc.ActiveView;
view.SetElementOverrides(el, ogs);

trans.Commit();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: