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;

        Transaction ts =  new Transaction(uiDoc.Document,  " http://revit.5d6d.com ");
        ts.Start();

        Wall wall = uiDoc.Document.GetElement(uiDoc.Selection.PickObject(ObjectType.Element,  " wall "))  as Wall;
         // 取得一种材质
        Materials materials = doc.Settings.Materials;
        ElementId materialId = materials.get_Item( " 隔热层/保温层 - 空心填充 ").Id;
         // 得到墙结果
        CompoundStructure cs = wall.WallType.GetCompoundStructure();
         // ElementId matId = Material.Create(doc, "MyMaterial"); // 创建材质
        
// 创建保温层(厚度,功能,材质)
        CompoundStructureLayer layer =  new CompoundStructureLayer( 100 /  304.8, MaterialFunctionAssignment.Insulation, materialId);
        cs.SetLayer(cs.GetFirstCoreLayerIndex(), layer);
         // 修改墙体厚度
        IList<CompoundStructureLayer> listLayer = cs.GetLayers();
         int iIdx =  0;
         foreach (CompoundStructureLayer cLayer  in listLayer)
        {
             if (MaterialFunctionAssignment.Structure == cLayer.Function)
            {
                 break;
            }
            iIdx +=  1;
        }
        cs.SetLayerWidth(iIdx,  400 /  304.8);
         // 调用更新
        wall.WallType.SetCompoundStructure(cs);

        ts.Commit();

         return Result.Succeeded;
    }
}
url: http://greatverve.cnblogs.com/p/revit-api-CompoundStructure.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值