zoukankan      html  css  js  c++  java
  • Revit API创建墙的保温层修改墙厚度

    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
  • 相关阅读:
    面试题:JS中map的陷阱
    C#中正则表达式进行忽略大小写的字符串替换
    C#窗体钉在桌面、置底、嵌入桌面的办法
    创建C#串口通信程序详解
    为类和函数代码自动添加版权注释信息
    C# 如何编辑文件的摘要信息
    C# GDI在控件上绘图
    泛型Dictionary的用法详解
    Winform 导出成Excel打印代码
    C#反射深入学习
  • 原文地址:https://www.cnblogs.com/greatverve/p/revit-api-CompoundStructure.html
Copyright © 2011-2022 走看看