首页 > Windows开发 > 详细

Revit API修改保温层厚度

时间:2014-03-01 23:23:52      阅读:906      评论:0      收藏:0      [点我收藏+]
start
bubuko.com,布布扣
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
    public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
    {
        UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
        Document doc = uiDoc.Document;
        Selection selection = uiDoc.Selection;

        Transaction ts = new Transaction(doc, this.ToString());
        ts.Start();
        //
        Reference refWall = selection.PickObject(ObjectType.Element, "选择墙:");
        Wall wall = doc.GetElement(refWall) as Wall;
        WallType wallType = wall.WallType;
        CompoundStructure cs = wallType.GetCompoundStructure();
        bool bHas = false;//是否拥有保温层
        int iWidth = 100;//要设置的保温层厚度
        IList<CompoundStructureLayer> layers = cs.GetLayers();//找到所有层
        foreach (CompoundStructureLayer layer in layers)
        {
            if (layer.Function == MaterialFunctionAssignment.Insulation)//判断保温层
            {
                bHas = true;
                layer.Width = iWidth / 304.8;
            }
        }
        if (!bHas)//没有保温层则创建
        {
            CompoundStructureLayer newLayer = new CompoundStructureLayer();
            newLayer.Function = MaterialFunctionAssignment.Insulation;
            newLayer.Width = iWidth / 304.8;
            //layers.Add(newLayer);
            layers.Insert(0, newLayer);
        }
        cs.SetLayers(layers);
        wallType.SetCompoundStructure(cs);
        //
        ts.Commit();

        return Result.Succeeded;
    }
}
bubuko.com,布布扣
url:http://greatverve.cnblogs.com/p/revit-api-CompoundStructureLayer.html

Revit API修改保温层厚度,布布扣,bubuko.com

Revit API修改保温层厚度

原文:http://www.cnblogs.com/greatverve/p/revit-api-CompoundStructureLayer.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!