示例#1
0
 private void SetProperties()
 {
     BoundingBoxXYZ = _element.get_BoundingBox(null);
     if (_element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Walls)
     {
         HostType = HostType.Wall;
         Wall wall = _element as Wall;
         Thickness = Math.Round(UnitUtils.ConvertFromInternalUnits(wall.Width, DisplayUnitType.DUT_MILLIMETERS), 1);
     }
     if (_element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Floors)
     {
         HostType = HostType.Floor;
         Floor floor = _element as Floor;
         Thickness = Math.Round(UnitUtils.ConvertFromInternalUnits(floor.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM).AsDouble(), DisplayUnitType.DUT_MILLIMETERS), 1);
     }
     if (_element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Ceilings)
     {
         HostType = HostType.Ceiling;
         Ceiling     ceiling = _element as Ceiling;
         ElementId   typeId  = ceiling.GetTypeId();
         CeilingType cType   = _document.GetElement(typeId) as CeilingType;
         Thickness = Math.Round(UnitUtils.ConvertFromInternalUnits(cType.get_Parameter(BuiltInParameter.CEILING_THICKNESS).AsDouble(), DisplayUnitType.DUT_MILLIMETERS), 1);
     }
     if (_element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Roofs)
     {
         HostType  = HostType.Roof;
         Thickness = Math.Round(UnitUtils.ConvertFromInternalUnits(_element.get_Parameter(BuiltInParameter.ROOF_ATTR_THICKNESS_PARAM).AsDouble(), DisplayUnitType.DUT_MILLIMETERS), 1);
     }
 }
示例#2
0
        private List <Ceiling> CreateCeilings(Room room, List <Ceiling> ceilingsFound, CeilingType ceilingType, ref StringBuilder msgBuilder)
        {
            var copiedCeilings = new List <Ceiling>();

            try
            {
                foreach (var ceiling in ceilingsFound)
                {
                    using (var trans = new Transaction(Doc))
                    {
                        trans.Start("Copy Ceiling");
                        try
                        {
                            double finishThickness = 0;
                            var    param           = ceilingType.get_Parameter(BuiltInParameter.CEILING_THICKNESS);
                            if (null != param)
                            {
                                if (param.HasValue)
                                {
                                    finishThickness = param.AsDouble();
                                }
                            }

                            var copiedIds = ElementTransformUtils.CopyElement(Doc, ceiling.Id, new XYZ(0, 0, -finishThickness));
                            trans.Commit();

                            trans.Start("Change Ceiling Type");
                            if (copiedIds.Count > 0)
                            {
                                var copiedCeilingId = copiedIds.First();
                                var copiedCeiling   = Doc.GetElement(copiedCeilingId) as Ceiling;
                                if (null != copiedCeiling)
                                {
                                    var changedTypeId = copiedCeiling.ChangeTypeId(ceilingType.Id);
                                    copiedCeilings.Add(copiedCeiling);
                                }
                            }
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            msgBuilder.AppendLine(ceiling.Name + " [" + ceiling.Id.IntegerValue + "]: cannot be copied\n" + ex.Message);
                            trans.RollBack();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cannot create ceilings from the selected rooms.\nRoom Id:" + room.Id.IntegerValue + "\n\n" + ex.Message, "Create Ceilings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(copiedCeilings);
        }