Revit API修改保温层厚度

本文介绍如何使用 Revit API 实现对墙体保温层的设置。通过检测墙体类型中的复合结构来判断是否存在保温层,并对其进行修改或新增。具体实现包括获取活动文档、选取墙元素、读取墙类型及复合结构等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

start
[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;
    }
}
url: http://greatverve.cnblogs.com/p/revit-api-CompoundStructureLayer.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值