神仙客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
//修改对象颜色

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

 

posted on 2014-05-19 14:59  神仙客  阅读(1979)  评论(0编辑  收藏  举报