예제 #1
0
        public HorizontalFinishingResult(Room room, ElementType elementType, double offset)
        {
            Room          = room;
            Level         = room.Level;
            FinishingType = elementType;
            Offset        = offset;

            ///
            /// Находим все профили помещения и сортируем по периметру. Самый длинный - контур перекрытия
            ///
            List <List <Curve> > roomsCountours = CurveUtils.GetCurvesListFromSpatialElement(room);

            for (int i = 0; i < roomsCountours.Count; i++)
            {
                CurveUtils.FixContourProblems(roomsCountours[i]);
            }
            roomsCountours = roomsCountours.OrderBy(x => x.Sum(y => y.Length)).ToList();
            MainProfile    = ConvertListToCurveArray(roomsCountours.Last());
            ///
            /// Остальное - вырезы
            ///
            OpeningProfiles = new List <CurveArray>();
            for (int i = 0; i < roomsCountours.Count - 1; i++)
            {
                OpeningProfiles.Add(ConvertListToCurveArray(roomsCountours[i]));
            }
        }
예제 #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document  doc       = commandData.Application.ActiveUIDocument.Document;
            Selection selection = commandData.Application.ActiveUIDocument.Selection;
            SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions();
            ModelCurveCreator             mmc = new ModelCurveCreator(doc);

            IList <Reference> rooms = selection.PickObjects(ObjectType.Element, new RoomFilter(), "Выберите помещения");

            try
            {
                using (Transaction tr = new Transaction(doc, "Создание контуров"))
                {
                    tr.Start();
                    foreach (Reference roomref in rooms)
                    {
                        CurveArray     curves = new CurveArray();
                        SpatialElement room   = doc.GetElement(roomref.ElementId) as SpatialElement;
                        foreach (var boundary in CurveUtils.GetCurvesListFromSpatialElement(room))
                        {
                            foreach (var curve in boundary)
                            {
                                curves.Append(curve);
                            }
                        }
                        mmc.DrawGroup(curves, string.Format("Контур {0} #{1}", room.Category.Name, room.Number));
                    }
                    TaskDialog.Show("Результат", "Создано групп контуров: " + rooms.Count.ToString());
                    tr.Commit();
                }
            }
            catch
            {
                return(Result.Failed);
            }
            return(Result.Succeeded);
        }