コード例 #1
0
ファイル: FromRevit.cs プロジェクト: chuongmep/Revit_Toolkit
        /***************************************************/

        public static IEnumerable <IBHoMObject> FromRevit(this FamilyInstance familyInstance, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            if (AdaptiveComponentInstanceUtils.IsAdaptiveComponentInstance(familyInstance))
            {
                BH.oM.Adapters.Revit.Elements.ModelInstance instance = familyInstance.ModelInstanceFromRevit(settings, refObjects);

                if (instance != null && transform?.IsIdentity == false)
                {
                    TransformMatrix bHoMTransform = transform.FromRevit();
                    instance = instance.Transform(bHoMTransform) as BH.oM.Adapters.Revit.Elements.ModelInstance;
                }

                return(new List <IBHoMObject> {
                    instance
                });
            }
            else
            {
                IEnumerable <IElement> result = null;
                switch (discipline)
                {
                case Discipline.Structural:
                    if (typeof(Bar).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = familyInstance.BarsFromRevit(settings, refObjects);
                    }
                    break;

                case Discipline.Physical:
                case Discipline.Architecture:
                    if (typeof(BH.oM.Physical.Elements.Window).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = new List <IElement> {
                            familyInstance.WindowFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    else if (typeof(BH.oM.Physical.Elements.Door).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = new List <IElement> {
                            familyInstance.DoorFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    else if (typeof(BH.oM.Physical.Elements.Column).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Column)
                    {
                        result = new List <IElement> {
                            familyInstance.ColumnFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    else if (typeof(BH.oM.Physical.Elements.Bracing).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Brace)
                    {
                        result = new List <IElement> {
                            familyInstance.BracingFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    else if (typeof(BH.oM.Physical.Elements.Beam).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = new List <IElement> {
                            familyInstance.BeamFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    break;

                case Discipline.Environmental:
                    result = new List <IElement> {
                        familyInstance.EnvironmentPanelFromRevit(settings, refObjects)
                    };
                    break;

                case Discipline.Facade:
                    if (typeof(BH.oM.Facade.Elements.Opening).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = new List <IElement> {
                            familyInstance.FacadeOpeningFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    else if (typeof(BH.oM.Facade.Elements.FrameEdge).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                    {
                        result = new List <IElement> {
                            familyInstance.FrameEdgeFromRevit(settings, refObjects)
                        }
                    }
                    ;
                    break;
                }

                if (result != null && transform?.IsIdentity == false)
                {
                    TransformMatrix bHoMTransform = transform.FromRevit();
                    result = result.Select(x => x?.ITransform(bHoMTransform));
                }

                return(result?.Cast <IBHoMObject>().ToList());
            }
        }
コード例 #2
0
        /***************************************************/

        public static IEnumerable <IBHoMObject> FromRevit(this FamilyInstance familyInstance, Discipline discipline, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            switch (discipline)
            {
            case Discipline.Structural:
                if (typeof(BH.oM.Structure.Elements.Bar).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                {
                    return(familyInstance.BarsFromRevit(settings, refObjects).Cast <IBHoMObject>());
                }
                else
                {
                    return(null);
                }

            case Discipline.Physical:
            case Discipline.Architecture:
                if (typeof(BH.oM.Physical.Elements.Window).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                {
                    return new List <IBHoMObject> {
                               familyInstance.WindowFromRevit(settings, refObjects)
                    }
                }
                ;
                if (typeof(BH.oM.Physical.Elements.Door).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                {
                    return new List <IBHoMObject> {
                               familyInstance.DoorFromRevit(settings, refObjects)
                    }
                }
                ;
                if (typeof(BH.oM.Physical.Elements.Column).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Column)
                {
                    return new List <IBHoMObject> {
                               familyInstance.ColumnFromRevit(settings, refObjects)
                    }
                }
                ;
                if (typeof(BH.oM.Physical.Elements.Bracing).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Brace)
                {
                    return new List <IBHoMObject> {
                               familyInstance.BracingFromRevit(settings, refObjects)
                    }
                }
                ;
                if (typeof(BH.oM.Physical.Elements.Beam).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue))
                {
                    return new List <IBHoMObject> {
                               familyInstance.BeamFromRevit(settings, refObjects)
                    }
                }
                ;
                else
                {
                    return(null);
                }

            case Discipline.Environmental:
                return(new List <IBHoMObject> {
                    familyInstance.EnvironmentPanelFromRevit(settings, refObjects)
                });

            default:
                return(null);
            }
        }