コード例 #1
0
ファイル: Client.cs プロジェクト: samuto/Grevit
        public Client(RevitFamilyCollection FamiliesToRespond)
        {
            InitializeComponent();

            // Prepare the Revit Familytree of the current document for sending
            this.FamiliesToRespond = Utilities.Serialize(FamiliesToRespond);
        }
コード例 #2
0
ファイル: Utilities.cs プロジェクト: bbrangeo/Grevit
        /// <summary>
        /// Get Revit Families from the active Document
        /// </summary>
        public static RevitFamilyCollection GetFamilies(this Document document)
        {
            // create a new family collection
            Grevit.Types.RevitFamilyCollection familyCollection = new Grevit.Types.RevitFamilyCollection();

            // set up a new category List
            familyCollection.Categories = new List<Grevit.Types.RevitCategory>();

            // Get all WallTypes and add them to the system family category
            #region WallTypes

            FilteredElementCollector collector = new FilteredElementCollector(document).OfClass(typeof(WallType));

            RevitCategory systemFamilies = new RevitCategory()
            {
                Name = "System Families",
                Families = new List<RevitFamily>()
            };

            RevitFamily wallTypes = new RevitFamily()
            {
                Name = "Walls",
                Types = new List<string>()
            };

            foreach (WallType wallType in collector.ToElements())
                wallTypes.Types.Add(wallType.Name);

            systemFamilies.Families.Add(wallTypes);
            familyCollection.Categories.Add(systemFamilies);

            #endregion

            // Get all Family Instances and add them to the Grevit Family collection
            #region familyInstances

            FilteredElementCollector familyInstanceCollector = new FilteredElementCollector(document).OfClass(typeof(FamilySymbol));

            foreach (Autodesk.Revit.DB.FamilySymbol familySymbol in familyInstanceCollector.ToElements())
            {
                RevitFamily family = null;
                RevitCategory category = null;

                // Check if category already exists
                foreach (RevitCategory revitCategory in familyCollection.Categories)
                    if (revitCategory.Name == familySymbol.Category.Name) category = revitCategory;

                // Otherwise create a new category
                if (category == null)
                {
                    category = new RevitCategory()
                    {
                        Name = familySymbol.Category.Name,
                        Families = new List<RevitFamily>()
                    };

                    familyCollection.Categories.Add(category);
                }

                // Check if Family already exists
                foreach (RevitFamily revitFamily in category.Families)
                    if (revitFamily.Name == familySymbol.FamilyName) family = revitFamily;

                // Otherwise create a new one
                if (family == null)
                {
                    family = new RevitFamily()
                    {
                        Name = familySymbol.FamilyName,
                        Types = new List<string>()
                    };

                    category.Families.Add(family);
                }

                family.Types.Add(familySymbol.Name);

            }

            #endregion

            return familyCollection;
        }
コード例 #3
0
ファイル: Utilities.cs プロジェクト: mdengusiak/Grevit
        /// <summary>
        /// Get Revit Families from the active Document
        /// </summary>
        public static RevitFamilyCollection GetFamilies(this Document document)
        {
            // create a new family collection
            Grevit.Types.RevitFamilyCollection familyCollection = new Grevit.Types.RevitFamilyCollection();

            // set up a new category List
            familyCollection.Categories = new List <Grevit.Types.RevitCategory>();

            // Get all WallTypes and add them to the system family category
            #region WallTypes

            FilteredElementCollector collector = new FilteredElementCollector(document).OfClass(typeof(WallType));

            RevitCategory systemFamilies = new RevitCategory()
            {
                Name     = "System Families",
                Families = new List <RevitFamily>()
            };

            RevitFamily wallTypes = new RevitFamily()
            {
                Name  = "Walls",
                Types = new List <string>()
            };

            foreach (WallType wallType in collector.ToElements())
            {
                wallTypes.Types.Add(wallType.Name);
            }

            systemFamilies.Families.Add(wallTypes);
            familyCollection.Categories.Add(systemFamilies);

            #endregion

            // Get all Family Instances and add them to the Grevit Family collection
            #region familyInstances

            FilteredElementCollector familyInstanceCollector = new FilteredElementCollector(document).OfClass(typeof(FamilySymbol));

            foreach (Autodesk.Revit.DB.FamilySymbol familySymbol in familyInstanceCollector.ToElements())
            {
                RevitFamily   family   = null;
                RevitCategory category = null;

                // Check if category already exists
                foreach (RevitCategory revitCategory in familyCollection.Categories)
                {
                    if (revitCategory.Name == familySymbol.Category.Name)
                    {
                        category = revitCategory;
                    }
                }

                // Otherwise create a new category
                if (category == null)
                {
                    category = new RevitCategory()
                    {
                        Name     = familySymbol.Category.Name,
                        Families = new List <RevitFamily>()
                    };

                    familyCollection.Categories.Add(category);
                }

                // Check if Family already exists
                foreach (RevitFamily revitFamily in category.Families)
                {
                    if (revitFamily.Name == familySymbol.FamilyName)
                    {
                        family = revitFamily;
                    }
                }

                // Otherwise create a new one
                if (family == null)
                {
                    family = new RevitFamily()
                    {
                        Name  = familySymbol.FamilyName,
                        Types = new List <string>()
                    };

                    category.Families.Add(family);
                }

                family.Types.Add(familySymbol.Name);
            }

            #endregion

            return(familyCollection);
        }