예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outPutSolids"></param>
        /// <param name="parasiteObjects"></param>
        /// <param name="op"></param>
        /// <param name="doc"></param>
        public static void GeometryDataFromFloor(Element element, List <DynamoSolid> outPutSolids,
                                                 List <ParasiteObject> parasiteObjects, Options op)
        {
            if (element is Floor)
            {
                Floor           floor           = element as Floor;
                GeometryElement geometryElement = floor.get_Geometry(op);

                if (geometryElement != null)
                {
                    P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, floor.FloorType.Name, P_StorageType.String);
                    P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                    DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                  new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outPutSolids"></param>
        /// <param name="parasiteObjects"></param>
        /// <param name="OP"></param>
        public static void GeometryDataFromRoof(Element element, List <DynamoSolid> outPutSolids,
                                                List <ParasiteObject> parasiteObjects, Options OP)
        {
            if (element is RoofBase)
            {
                RoofBase        roofBase        = element as RoofBase;
                GeometryElement geometryElement = roofBase.get_Geometry(OP);

                // Skip if null
                if (geometryElement != null)
                {
                    P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, roofBase.RoofType.Name, P_StorageType.String);
                    P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                    DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                  new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// This method selects  all family instances from a given category, and returns
        /// a collection of Parasite Objects. Each Parasite Object will contain Revit data of each
        /// of the geometry. For example a given frame of a window will identify itself as a frame
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outPutSolids"></param>
        /// <returns></returns>
        public static void GeometryDataFromFamilyInstance(Element element, List <DynamoSolid> outPutSolids,
                                                          List <ParasiteObject> parasiteObjects, Options OP, Document doc)
        {
            if (element.Category.Name == "Windows")
            {
                GeometryElement geoElement = element.get_Geometry(OP);

                for (int i = 0; i < geoElement.Count(); i++)
                {
                    GeometryInstance geoInstance     = geoElement.ElementAt(i) as GeometryInstance;
                    GeometryElement  geometryElement = geoInstance.GetInstanceGeometry();

                    if (geometryElement != null)
                    {
                        foreach (GeometryObject item in geometryElement)
                        {
                            bool           success        = TryeGetGeometryDataFromGeometryObject(item, out Solid solid, out DynamoSolid dynS);
                            ParasiteObject parasiteObject = new ParasiteObject();

                            if (success)
                            {
                                // GraphicsStyle will never be null for windows
                                if (doc.GetElement(solid.GraphicsStyleId) is GraphicsStyle gStyle)
                                {
                                    P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, gStyle.GraphicsStyleCategory.Name, P_StorageType.String);
                                    P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                                    parasiteObject = DynamoParasiteFactory.CreateParasiteObject(dynS);
                                    DynamoParasiteFactory.AddParametersToParasiteObj(parasiteObject, new P_Parameter[] { paramChildLayer, paramLayer });
                                    parasiteObjects.Add(parasiteObject);
                                    outPutSolids.Add(dynS);
                                }

                                else
                                {
                                    throw new ParasiteConversionExceptions(element.GetType(), parasiteObject.GetType());
                                }
                            }
                        }
                    }
                }
            }

            else if (element.Category.Name == "Doors")
            {
                GeometryElement geoElement      = element.get_Geometry(OP);
                P_Parameter     paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, element.Name, P_StorageType.String);
                P_Parameter     paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                for (int i = 0; i < geoElement.Count(); i++)
                {
                    GeometryInstance geoInstance     = geoElement.ElementAt(i) as GeometryInstance;
                    GeometryElement  geometryElement = geoInstance.GetInstanceGeometry();

                    if (geometryElement != null)
                    {
                        DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                      new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                    }
                }
            }

            else
            {
                throw new ParasiteNotImplementedExceptions("Family Instance Category not implemented yet");
            }
        }
예제 #4
0
        /// <summary>
        /// Extracts a Dynamo Solid from a Revit Wall object and creates a ParasiteObject
        /// from the extracted geometry
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outPutSolids"></param>
        /// <param name="parasiteObjects"></param>
        /// <param name="OP"></param>
        /// <param name="doc"></param>
        public static void GeometryDataFromWall(Element element, List <DynamoSolid> outPutSolids,
                                                List <ParasiteObject> parasiteObjects, Options OP, Document doc)
        {
            if (element is WallType)
            {
                // Cast Element to WallType
                WallType wallType = element as WallType;

                // Get Geometry Element
                GeometryElement geometryElement = wallType.get_Geometry(OP);

                // Skip if null
                if (geometryElement != null)
                {
                    P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wallType.Name, P_StorageType.String);
                    P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                    DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                  new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                }
            } // END WALLTYPE CLASS CONDITION


            else if (element is Wall)
            {
                Wall        wall  = element as Wall;
                CurtainGrid cgrid = wall.CurtainGrid;

                //  THIS MEANS WALL IS A GLAZED CURTAIN WALL
                if (cgrid != null)
                {
                    ICollection <ElementId> panelIds = cgrid.GetPanelIds();
                    Element[] panels = panelIds.Select(a => doc.GetElement(a)).ToArray();

                    for (int p = 0; p < panels.Length; p++)
                    {
                        // Ignores Family instances in the Curtain wall. For example doors
                        if (!(panels[p] is Panel panel))
                        {
                            continue;
                        }

                        GeometryElement geometryElement = panel.get_Geometry(OP);

                        if (geometryElement != null)
                        {
                            P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, panel.Category.Name, P_StorageType.String);
                            P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                            DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                          new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                        }
                    }

                    ICollection <ElementId> mullionIds = cgrid.GetMullionIds();
                    Element[] mullions = mullionIds.Select(a => doc.GetElement(a)).ToArray();

                    for (int m = 0; m < mullions.Length; m++)
                    {
                        Mullion mullion = mullions[m] as Mullion;

                        //if (!(mullions[m] is Mullion mullion)) continue;

                        GeometryElement geometryElement = mullion.get_Geometry(OP);

                        if (geometryElement != null)
                        {
                            P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, mullion.Category.Name, P_StorageType.String);
                            P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                            DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                          new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                        }
                    }
                } // End of wall that is a curtain wall

                // THIS MEANS ITS A NORMAL WALL
                else
                {
                    GeometryElement geometryElement = element.get_Geometry(OP);
                    if (geometryElement != null)
                    {
                        P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wall.WallType.Name, P_StorageType.String);
                        P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                        DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                      new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                    }
                }
            } // END WALL CLASS CONDITION

            else
            {
                throw new ParasiteNotImplementedExceptions("Wall type not implemented yet");
            }
        }