Exemplo n.º 1
0
        public List <ObjDoors> CurrentModelDoors(Document doc)
        {
            List <ObjDoors> currentModelDoors = new List <ObjDoors>();

            {
                LibraryGetItems library = new LibraryGetItems();
                List <Element>  doors   = library.GetFamilyElement(doc, BuiltInCategory.OST_Doors);
                foreach (Element door in doors)
                {
                    LocationPoint location = door.Location as LocationPoint;
                    // Get level id parameter
                    Parameter levelId = door.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM);
                    // Get level value of id parameter
                    string parmLevel_Id = library.GetParameterValue(levelId);
                    // get all levels in current model
                    List <Level> levels = library.GetLevels(doc);
                    // find and match of door level and current model level to get level
                    Level levelName = levels.Find(x => Convert.ToString(x.Id.IntegerValue) == parmLevel_Id);

                    FamilySymbol familySymbol = library.GetFamilySymbol(doc, door.Name, BuiltInCategory.OST_Doors);
                    // find unique identification of door
                    //1bb68248-4b34-4821-9be3-8ddf47852209 = SOM ID
                    var    SOMIDParam = door.LookupParameter("SOM ID");
                    string doorId     = library.GetParameterValue(SOMIDParam);

                    ObjDoors ObjectDoor = new ObjDoors();
                    ObjectDoor.doorElement = door;
                    ObjectDoor.doorName    = door.Name;
                    ObjectDoor.doorId      = doorId;
                    ObjectDoor.doorWidth   = familySymbol.get_Parameter(BuiltInParameter.FAMILY_ROUGH_WIDTH_PARAM).AsDouble();
                    ObjectDoor.doorHeight  = familySymbol.get_Parameter(BuiltInParameter.FAMILY_ROUGH_HEIGHT_PARAM).AsDouble();
                    ObjectDoor.X           = location.Point.X;
                    ObjectDoor.Y           = location.Point.Y;
                    ObjectDoor.Z           = location.Point.Z;
                    ObjectDoor.level       = levelName;
                    currentModelDoors.Add(ObjectDoor);
                }
            }
            return(currentModelDoors);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get linked model and select all the doors.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="uiApp"></param>
        /// <returns>Object of doors</returns>
        public List <ObjDoors> LinkedModelDoors(Document doc, UIApplication uiApp)
        {
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            IList <Element> elems = collector
                                    .OfCategory(BuiltInCategory.OST_RvtLinks)
                                    .OfClass(typeof(RevitLinkType))
                                    .ToElements();

            List <ObjDoors> LinkedModelDoors = new List <ObjDoors>();

            foreach (Element e in elems)
            {
                RevitLinkType linkType = e as RevitLinkType;
                String        s        = String.Empty;

                foreach (Document linkedDoc in uiApp.Application.Documents)
                {
                    if (linkedDoc.Title.Equals(linkType.Name))
                    {
                        LibraryGetItems library = new LibraryGetItems();
                        List <Element>  doors   = library.GetFamilyElement(linkedDoc, BuiltInCategory.OST_Doors);
                        foreach (Element door in doors)
                        {
                            try
                            {
                                LocationPoint location = door.Location as LocationPoint;
                                // Get level id parameter
                                Parameter levelId = door.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM);
                                // Get level value of id parameter
                                string parmLevel_Id = library.GetParameterValue(levelId);
                                // get all levels in linked model
                                List <Level> levels = library.GetLevels(linkedDoc);
                                // find and match of door level and linked model level to get level
                                Level levelName = levels.Find(x => Convert.ToString(x.Id.IntegerValue) == parmLevel_Id);

                                FamilySymbol familySymbol = library.GetFamilySymbol(linkedDoc, door.Name, BuiltInCategory.OST_Doors);
                                // find unique identification of door\
                                ObjDoors ObjectDoor = new ObjDoors();
                                ObjectDoor.doorElement = door;
                                ObjectDoor.doorName    = door.Name;
                                ObjectDoor.doorId      = door.Id.ToString();

                                ObjectDoor.doorWidth = door.get_Parameter(BuiltInParameter.DOOR_WIDTH).AsDouble();
                                try
                                {
                                    if (ObjectDoor.doorWidth == 0.0)
                                    {
                                        ObjectDoor.doorWidth = familySymbol.get_Parameter(BuiltInParameter.DOOR_WIDTH).AsDouble();
                                    }
                                }
                                catch { }

                                ObjectDoor.doorHeight = door.get_Parameter(BuiltInParameter.DOOR_HEIGHT).AsDouble();
                                try
                                {
                                    if (ObjectDoor.doorHeight == 0.0)
                                    {
                                        ObjectDoor.doorHeight = familySymbol.get_Parameter(BuiltInParameter.DOOR_HEIGHT).AsDouble();
                                    }
                                }
                                catch { }

                                ObjectDoor.doorSillHeight = door.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM).AsDouble();

                                ObjectDoor.X     = location.Point.X;
                                ObjectDoor.Y     = location.Point.Y;
                                ObjectDoor.Z     = location.Point.Z;
                                ObjectDoor.level = levelName;

                                FamilyInstance familyInstance = door as FamilyInstance;
                                ObjectDoor.HostObj = familyInstance.Host.Id.IntegerValue;
                                ObjectDoor.wall    = linkedDoc.GetElement(familyInstance.Host.Id) as Wall;
                                LinkedModelDoors.Add(ObjectDoor);
                            }
                            catch (Exception er)
                            {
                                string error = er.Message;
                            }
                        }
                    }
                }
            }
            return(LinkedModelDoors);
        }