Esempio n. 1
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            // Revit application documents.
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            program Program = new program();
            // Linked model doors
            List <ObjDoors> List_DoorsLinkedModel = new List <ObjDoors>();
            LinkedModel     linkedModel           = new LinkedModel();

            // Current model doors
            List <ObjDoors> List_DoorsCurrentModel = new List <ObjDoors>();

            LocalModel localModel = new LocalModel();

            // get doors from linked model
            List_DoorsLinkedModel = linkedModel.LinkedModelDoors(doc, uiapp);

            // get doors from current model.
            List_DoorsCurrentModel = localModel.CurrentModelDoors(doc);
            // Remove elevator doors labeled STRUC
            List_DoorsCurrentModel.RemoveAll(x => x.doorId == "STRUC");

            List <ObjDoors> listCreatedDoors = Program.DoorProgram(doc, uidoc, List_DoorsLinkedModel, List_DoorsCurrentModel);

            // Export to Excel to see information.
            ExportExcel exportExcel = new ExportExcel();

            if (listCreatedDoors != null)
            {
                exportExcel.ExportToExcel(listCreatedDoors, "Created Door Information");
            }

            //exportExcel.ExportToExcel(List_DoorsLinkedModel, "Linked Door Information");

            return(Result.Succeeded);
        }
Esempio n. 2
0
        //*****************************DoorProgram()*****************************
        public List <ObjDoors> DoorProgram(Document doc, UIDocument uidoc,
                                           List <ObjDoors> List_DoorsLinkedModel, List <ObjDoors> List_DoorsCurrentModel)
        {
            List <ObjDoors> ListObjDoors = new List <ObjDoors>();
            // logger object.
            Logger      logger      = LogManager.GetLogger("program");
            ExportExcel exportExcel = new ExportExcel();

            // Get all levels and add to field.
            LibraryGetItems libGetItems = new LibraryGetItems();

            _ListLevels = libGetItems.GetLevels(doc);

            foreach (ObjDoors linkedDoor in List_DoorsLinkedModel)
            {
                // check to see if door exist
                ObjDoors DoorFound = List_DoorsCurrentModel.Find(x => x.doorId == linkedDoor.doorId);
                // if it doesn't exist it will create a new door.
                if (DoorFound == null)
                {
                    try
                    {
                        ObjDoors door = CreateDoors(uidoc, doc, linkedDoor);
                        ListObjDoors.Add(door);
                    }
                    catch (Exception e)
                    {
                        string ErrMessage = e.Message;
                    }
                }

                // if door exist the check to see if the location is the same and type.
                if (DoorFound != null)
                {
                    try
                    {
                        MoveDoors(doc, linkedDoor, DoorFound);
                    }
                    catch (Exception e)
                    {
                        string ErrMessage = e.Message;
                    }

                    // Get all the levels from current project.
                    Level level = findLevel(doc, linkedDoor);

                    // Level offset from architecture.
                    LibraryGetItems     Library       = new LibraryGetItems();
                    LibraryConvertUnits library_Units = new LibraryConvertUnits();
                    double offset       = 0;
                    Level  CurrentLevel = _ListLevels.Find(x => x.Name == level.Name);
                    try
                    {
                        Parameter parameter_LevelOffsetFF = CurrentLevel.LookupParameter("LEVEL OFFSET FF");
                        offset = library_Units.InchesToFeet(Convert.ToDouble(Library.GetParameterValue(parameter_LevelOffsetFF)));
                    }
                    catch { }

                    // Check to see if door size match.
                    double height   = Math.Round(linkedDoor.doorHeight + offset, 3);
                    double width    = Math.Round(linkedDoor.doorWidth, 3);
                    String doorType = doorTypeByUnits(doc, height, width);

                    if (doorType != "0 x 0")
                    {
                        if (DoorFound.doorName != doorType)
                        {
                            //FamilySymbol familySymbol = findSymbol(doc, DoorFound, doorType);
                            FamilySymbol familySymbol = FindElementByName(doc, typeof(FamilySymbol), doorType) as FamilySymbol;
                            if (familySymbol == null)
                            {
                                FamilySymbol oldType = findSymbol(doc, DoorFound);

                                FamilySymbol ChangeFamilySymbol = CreateNewType(doc, oldType, linkedDoor, offset);
                                //FamilySymbol ChangeFamilySymbol = BKK_CreateNewType(doc, oldType, linkedDoor);
                                changeType(doc, DoorFound, ChangeFamilySymbol);
                            }
                            if (familySymbol != null)
                            {
                                changeType(doc, DoorFound, familySymbol);
                            }
                        }
                    }
                }
            }
            //REMOVE UNSUED DOORS.
            RemoveUnused(doc, List_DoorsLinkedModel, List_DoorsCurrentModel);

            return(ListObjDoors);
        }