示例#1
0
        public WallType CreateNewWallType(Document doc, Wall wall)
        {
            WallType wallType    = wall.WallType;
            WallType NewWallType = null;

            Transaction t = new Transaction(doc, "Duplicate wall");

            t.Start();
            try
            {
                NewWallType = wallType.Duplicate("SW48") as WallType;
                CompoundStructure compoundStructure = NewWallType.GetCompoundStructure();
                int layerIndex = compoundStructure.GetFirstCoreLayerIndex();
                IList <CompoundStructureLayer> csLayers = compoundStructure.GetLayers();
                foreach (CompoundStructureLayer csl in csLayers)
                {
                    if (csl.Function.ToString() == "Structure")
                    {
                        compoundStructure.SetLayerWidth(layerIndex, 48 / 12);
                    }
                    layerIndex++;
                }
                NewWallType.SetCompoundStructure(compoundStructure);
            }
            catch {}
            t.Commit();
            return(NewWallType);
        }
        public WallType CreateWallType(Document document, WallType _wallType, double wallTypeThickness)
        {
            WallType wallType = null;

            try
            {
                wallType = _wallType.Duplicate($"Wall {Convert.ToInt32((wallTypeThickness )).ToString() }mm") as WallType;

                CompoundStructure compoundStructure = wallType.GetCompoundStructure();

                int layerIndex = compoundStructure.GetFirstCoreLayerIndex();


                IList <CompoundStructureLayer> clayers = compoundStructure.GetLayers();

                foreach (CompoundStructureLayer csl in clayers)
                {
                    if (csl.Function.ToString() == "Structure")
                    {
                        compoundStructure.SetLayerWidth(layerIndex, wallTypeThickness * _mm_to_feet);
                    }

                    layerIndex++;
                }

                wallType.SetCompoundStructure(compoundStructure);
            }
            catch { }


            return(wallType);
        }