Esempio n. 1
0
        void FloorFinish(UIDocument UIDoc, Transaction tx)
        {
            Document document = UIDoc.Document;

            FloorsFinishesSetup floorsFinishesSetup = new FloorsFinishesSetup();


            //Load the selection form

            FloorsFinishesControl floorsFinishesControl = new FloorsFinishesControl(UIDoc, floorsFinishesSetup);

            floorsFinishesControl.InitializeComponent();

            if (floorsFinishesControl.ShowDialog() == true)
            {
                CreateFloors(document, floorsFinishesSetup, tx);
            }
            else
            {
                if (tx.HasStarted())
                {
                    tx.RollBack();
                }
            }
        }
Esempio n. 2
0
        public void CreateFloors(Document document, FloorsFinishesSetup floorsFinishesSetup, Transaction tx)
        {
            tx.Start(Tools.LangResMan.GetString("floorFinishes_transactionName", Tools.Cult));

            foreach (Room room in floorsFinishesSetup.SelectedRooms)
            {
                if (room != null)
                {
                    if (room.UnboundedHeight != 0)
                    {
                        //Get all finish properties
                        double height;
                        if (floorsFinishesSetup.RoomParameter == null)
                        {
                            height = floorsFinishesSetup.FloorHeight;
                        }
                        else
                        {
                            Parameter roomParameter = room.get_Parameter(floorsFinishesSetup.RoomParameter.Definition);
                            height = roomParameter.AsDouble();
                        }

                        SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions();


                        IList <IList <Autodesk.Revit.DB.BoundarySegment> > boundarySegments = room.GetBoundarySegments(opt);

                        CurveArray curveArray = new CurveArray();

                        if (boundarySegments.Count != 0)
                        {
                            foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundarySegments.First())
                            {
                                curveArray.Append(boundSeg.GetCurve());
                            }


                            //Retrive room info
                            Level     rmLevel  = document.GetElement(room.LevelId) as Level;
                            Parameter param    = room.get_Parameter(BuiltInParameter.ROOM_HEIGHT);
                            double    rmHeight = param.AsDouble();

                            if (curveArray.Size != 0)
                            {
                                Floor floor = document.Create.NewFloor(curveArray, floorsFinishesSetup.SelectedFloorType, rmLevel, false);

                                //Change some param on the floor
                                param = floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM);
                                param.Set(height);
                            }
                        }
                    }
                }
            }

            tx.Commit();
        }
Esempio n. 3
0
        public FloorsFinishesControl(UIDocument UIDoc, FloorsFinishesSetup floorsFinishesSetup)
        {
            InitializeComponent();
            _doc   = UIDoc.Document;
            _UIDoc = UIDoc;
            FloorsFinishesSetup = floorsFinishesSetup;

            //Fill out Text in form
            this.Title = Tools.LangResMan.GetString("floorFinishes_TaskDialogName", Tools.Cult);
            this.all_rooms_radio.Content      = Tools.LangResMan.GetString("roomFinishes_all_rooms_radio", Tools.Cult);
            this.floor_height_radio.Content   = Tools.LangResMan.GetString("floorFinishes_height_label", Tools.Cult);
            this.height_param_radio.Content   = Tools.LangResMan.GetString("floorFinishes_height_param_label", Tools.Cult);
            this.groupboxName.Header          = Tools.LangResMan.GetString("floorFinishes_groupboxName", Tools.Cult);
            this.select_floor_label.Content   = Tools.LangResMan.GetString("floorFinishes_select_floor_label", Tools.Cult);
            this.selected_rooms_radio.Content = Tools.LangResMan.GetString("roomFinishes_selected_rooms_radio", Tools.Cult);
            this.Cancel_Button.Content        = Tools.LangResMan.GetString("roomFinishes_Cancel_Button", Tools.Cult);
            this.Ok_Button.Content            = Tools.LangResMan.GetString("roomFinishes_OK_Button", Tools.Cult);

            //Select the floor type in the document
            IEnumerable <FloorType> floorTypes = from elem in new FilteredElementCollector(_doc).OfClass(typeof(FloorType))
                                                 let type = elem as FloorType
                                                            where type.IsFoundationSlab == false
                                                            select type;

            floorTypes = floorTypes.OrderBy(floorType => floorType.Name);

            // Bind ArrayList with the ListBox
            FloorTypeListBox.ItemsSource  = floorTypes;
            FloorTypeListBox.SelectedItem = FloorTypeListBox.Items[0];

            //Find a room
            IList <Element> roomList = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_Rooms).ToList();

            if (roomList.Count != 0)
            {
                //Get all double parameters
                Room room = roomList.First() as Room;

                List <Parameter> doubleParam = (from Parameter p in room.Parameters
                                                where p.Definition.ParameterType == ParameterType.Length
                                                select p).ToList();

                paramSelector.ItemsSource       = doubleParam;
                paramSelector.DisplayMemberPath = "Definition.Name";
                paramSelector.SelectedIndex     = 0;
            }
            else
            {
                paramSelector.IsEnabled      = false;
                height_param_radio.IsEnabled = false;
            }
        }