예제 #1
0
        static void Main(string[] args)
        {
            DatabaseIfc               db          = new DatabaseIfc(Console.In);
            IfcProject                project     = db.Project;
            IfcSpatialElement         rootElement = project.RootElement;
            List <IfcBuildingElement> elements    = project.Extract <IfcBuildingElement>();
            List <IfcFacetedBrep>     breps       = new List <IfcFacetedBrep>();

            foreach (IfcBuildingElement element in elements)
            {
                List <IfcRepresentation> reps = element.Representation.Representations;
                foreach (IfcRepresentation rep in reps)
                {
                    IfcShapeRepresentation sr = rep as IfcShapeRepresentation;
                    if (sr != null)
                    {
                        List <IfcRepresentationItem> items = sr.Items;
                        foreach (IfcRepresentationItem item in items)
                        {
                            IfcFacetedBrep fb = item as IfcFacetedBrep;
                            if (fb != null)
                            {
                                breps.Add(fb);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            DatabaseIfc            db          = new DatabaseIfc(Console.In);
            IfcProject             project     = db.Project;
            IfcSpatialElement      rootElement = project.RootElement();
            List <IfcBuiltElement> elements    = project.Extract <IfcBuiltElement>();         //IfcBuiltElement renamed from IfcBuildingElement
            List <IfcFacetedBrep>  breps       = new List <IfcFacetedBrep>();

            foreach (IfcBuiltElement element in elements)
            {
                IfcProductDefinitionShape representation = element.Representation;
                if (representation != null)
                {
                    foreach (IfcShapeModel rep in representation.Representations)
                    {
                        IfcShapeRepresentation sr = rep as IfcShapeRepresentation;
                        if (sr != null)
                        {
                            foreach (IfcRepresentationItem item in sr.Items)
                            {
                                IfcFacetedBrep fb = item as IfcFacetedBrep;
                                if (fb != null)
                                {
                                    breps.Add(fb);
                                }
                            }
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            DatabaseIfc db      = new DatabaseIfc(Console.In);
            IfcProject  project = db.Project;

            Console.Out.Write("Number of Stories in file :" + project.Extract <IfcBuildingStorey>().Count);
        }
예제 #4
0
        private void openFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ifc|*.ifc";
            ofd.ShowDialog();

            DatabaseIfc               db          = new DatabaseIfc(ofd.FileName);
            IfcProject                project     = db.Project;
            IfcSpatialElement         rootElement = project.RootElement;
            List <IfcBuildingElement> elements    = project.Extract <IfcBuildingElement>();
            List <IfcFacetedBrep>     breps       = new List <IfcFacetedBrep>();

            foreach (IfcBuildingElement element in elements)
            {
                //outputLabel.Content += element.Name+ "\n";
                IfcProductRepresentation representation = element.Representation;
                if (representation != null)
                {
                    foreach (IfcRepresentation rep in representation.Representations)
                    {
                        IfcShapeRepresentation sr = rep as IfcShapeRepresentation;
                        if (sr != null)
                        {
                            foreach (IfcRepresentationItem item in sr.Items)
                            {
                                Debug.WriteLine(item.GetType());
                                IfcFacetedBrep fb = item as IfcFacetedBrep;
                                if (fb != null)
                                {
                                    breps.Add(fb);
                                    outputLabel.Content += fb + "\n";
                                    /// Each IfcFacetedBrep has one IfcClosedShell called "Outer".
                                    /// IfcClosedShell has several IfcFaces called CfsFaces
                                    //foreach (var face in fb.Outer.CfsFaces)
                                    //{
                                    //    /// IfcFace has several IfcFaceOuterBounds called bounds
                                    //    foreach(var bound in face.Bounds)
                                    //    {
                                    //        /// Each IfcFaceOuterBound inherited from IfcFacetedBrep has IfcPolyLoop
                                    //        var loop = bound.Bound as IfcPolyloop;
                                    //        if(loop != null)
                                    //        {
                                    //            foreach(var point in loop.Polygon)
                                    //            {
                                    //               //point.Coordinates;
                                    //                outputLabel.Content += point.Coordinates + "\n";
                                    //            }
                                    //        }
                                    //    }
                                    //}
                                    //outputLabel.Content += fb.ToString() + "\n";
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ifc|*.ifc";
            ofd.ShowDialog();

            DatabaseIfc db      = new DatabaseIfc(ofd.FileName);
            IfcProject  project = db.Project;

            countStoryLabel.Content = ("Number of Stories in file :" + project.Extract <IfcBuildingStorey>().Count);
            levelTreeView.Items.Clear();
            foreach (var storey in project.Extract <IfcBuildingStorey>())
            {
                levelTreeView.Items.Add(storey.Name);
            }
        }
예제 #6
0
        private void openFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ifc|*.ifc";
            ofd.ShowDialog();

            DatabaseIfc               db          = new DatabaseIfc(ofd.FileName);
            IfcProject                project     = db.Project;
            IfcSpatialElement         rootElement = project.RootElement;
            List <IfcBuildingElement> elements    = project.Extract <IfcBuildingElement>();
            List <IfcFacetedBrep>     breps       = new List <IfcFacetedBrep>();

            foreach (IfcBuildingElement element in elements)
            {
                //outputLabel.Content += element.Name+ "\n";
                IfcProductRepresentation representation = element.Representation;
                if (representation != null)
                {
                    foreach (IfcRepresentation rep in representation.Representations)
                    {
                        IfcShapeRepresentation sr = rep as IfcShapeRepresentation;
                        if (sr != null)
                        {
                            foreach (IfcRepresentationItem item in sr.Items)
                            {
                                var ifcTopologicalRepItem = item as IfcTopologicalRepresentationItem;
                                var ifcGeometricRepItem   = item as IfcGeometricRepresentationItem;
                                var ifcMappedItem         = item as IfcMappedItem;
                                var ifcStyledItem         = item as IfcStyledItem;
                                if (ifcTopologicalRepItem != null)
                                {
                                    var ifcConnectedFaceSet = ifcTopologicalRepItem as IfcConnectedFaceSet;
                                    var ifcEdge             = ifcTopologicalRepItem as IfcEdge;
                                    var ifcFace             = ifcTopologicalRepItem as IfcFace;
                                    var ifcFaceBound        = ifcTopologicalRepItem as IfcFaceBound;
                                    var ifcPath             = ifcTopologicalRepItem as IfcPath;
                                    var ifcVertex           = ifcTopologicalRepItem as IfcVertex;
                                    var ifcLoop             = ifcTopologicalRepItem as IfcLoop;
                                }
                                else if (ifcGeometricRepItem != null)
                                {
                                    var ifcCompositeCurveSegment = ifcGeometricRepItem as IfcCompositeCurveSegment;
                                    var ifcCurve          = ifcGeometricRepItem as IfcCurve;
                                    var ifcDirection      = ifcGeometricRepItem as IfcDirection;
                                    var ifcPlacement      = ifcGeometricRepItem as IfcPlacement;
                                    var ifcPoint          = ifcGeometricRepItem as IfcPoint;
                                    var ifcSurface        = ifcGeometricRepItem as IfcSurface;
                                    var ifcVector         = ifcGeometricRepItem as IfcVector;
                                    var ifcBooleanResult  = ifcGeometricRepItem as IfcBooleanResult;
                                    var ifcSolidModel     = ifcGeometricRepItem as IfcSolidModel;
                                    var ifcHalfSpaceSolid = ifcGeometricRepItem as IfcHalfSpaceSolid;
                                    var ifcBoundingBox    = ifcGeometricRepItem as IfcBoundingBox;
                                    var ifcCartesianTransformationOperator = ifcGeometricRepItem as IfcCartesianTransformationOperator;
                                    var ifcSectionedSpine         = ifcGeometricRepItem as IfcSectionedSpine;
                                    var ifcGeometricSet           = ifcGeometricRepItem as IfcGeometricSet;
                                    var ifcFaceBasedSurfaceModel  = ifcGeometricRepItem as IfcFaceBasedSurfaceModel;
                                    var ifcShellBasedSurfaceModel = ifcGeometricRepItem as IfcShellBasedSurfaceModel;
                                }
                                else if (ifcMappedItem != null)
                                {
                                    var mapSource = ifcMappedItem.MappingSource;
                                    var mapTarget = ifcMappedItem.MappingTarget;
                                    foreach (var mappedItem in mapSource.MappedRepresentation.Items)
                                    {
                                        var itm = mappedItem as IfcExtrudedAreaSolid;
                                        Debug.WriteLine(itm.Depth);
                                        Debug.WriteLine(itm.SweptArea.ProfileName);
                                    }
                                }
                                else if (ifcStyledItem != null)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        static void Main(string[] args)         //Example as requested at http://forums.autodesk.com/t5/revit-api/opensource-api-for-reading-ifc-files/m-p/6435644#M17340
        {
            DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            di = Directory.GetParent(di.FullName);

            string      filename = Path.Combine(di.FullName, "IFC Model.ifc");
            DatabaseIfc db       = new DatabaseIfc(filename);
            IfcProject  project  = db.Project;
            List <IfcBuildingElement>      elements   = project.Extract <IfcBuildingElement>();
            Dictionary <string, MyElement> dictionary = new Dictionary <string, MyElement>();

            foreach (IfcBuildingElement element in elements)
            {
                string desc = (element as IfcColumn != null ? "COL" : (element as IfcBeam != null ? "BEAM" : ""));

                string mark = element.Tag;
                if (!string.IsNullOrEmpty(desc))
                {
                    if (dictionary.ContainsKey(mark))
                    {
                        dictionary[mark].mQuantity++;
                    }
                    else
                    {
                        string grade  = "";
                        double length = 0;
                        foreach (IfcRelDefinesByProperties rdp in element.IsDefinedBy)
                        {
                            IfcPropertySet pset = rdp.RelatingPropertyDefinition as IfcPropertySet;
                            if (pset == null)
                            {
                                continue;
                            }
                            foreach (IfcProperty property in pset.HasProperties)
                            {
                                IfcPropertySingleValue psv = property as IfcPropertySingleValue;
                                if (psv == null)
                                {
                                    continue;
                                }
                                if (string.Compare("Grade", psv.Name) == 0)
                                {
                                    grade = psv.NominalValue.Value.ToString();
                                }
                                else if (string.Compare("Length", psv.Name) == 0)
                                {
                                    IfcLengthMeasure lengthmeasure = psv.NominalValue as IfcLengthMeasure;
                                    if (lengthmeasure != null)
                                    {
                                        length = lengthmeasure.Measure;
                                    }
                                }
                            }
                        }
                        dictionary.Add(mark, new MyElement(mark, desc, element.ObjectType, grade, length));
                    }
                }
            }
            Console.WriteLine("Mark\tDescription\tSection\tGrade\tLength\tQty");

            foreach (MyElement element in dictionary.ToList().ConvertAll(x => x.Value).OrderBy(x => x.mMark))
            {
                Console.WriteLine(element.mMark + "\t" + element.mDescription + "\t" + element.mSection + "\t" + element.mGrade + "\t" + element.mLength + "\t" + element.mQuantity);
            }
        }
예제 #8
0
        protected override void OnLoad(EventArgs e)
        {
            _treeModify = false;

            testLayer = viewportLayout1.Layers.Add("testLayer", Color.Red);
            int testLayer1 = viewportLayout1.Layers.Add("onPlane", Color.Blue);

            spatialLayer = viewportLayout1.Layers.Add("spatialLayer", Color.Green);

            viewportLayout1.Layers[0].Name = "Default";
            //viewportLayout1.Layers[0].Color = Color.Gray;

            //viewportLayout1.Layers[spatialLayer].Visible = true;
            //viewportLayout1.Layers[0].Visible = false;

            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC Model.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC\\Martti_Ahtisaaren_RAK.ifc");                //gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\MOD-Padrão\\MOD-Padrão.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Blueberry031105_Complete_optimized.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Clinic_Handover_WithProperty3.ifc");      //Gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Duplex_A_20110907.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NER-38d.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NHS Office.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Office_A_20110811.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\porur duplex.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\c_rvt8_Townhouse.ifc");

            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\01 Fire Protection.ifc");
            DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\ArchiCAD IFC Buildsoft.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\Clinic_S_20110715_optimized.ifc");

            IfcProject project = db.Project;

            List <IfcBuildingElement> ifcBuildingElement = project.Extract <IfcBuildingElement>();

            List <IfcSpatialElement> ifcSpatialElement = project.Extract <IfcSpatialElement>();

            List <IfcDistributionElement> ifcDistributionElement = project.Extract <IfcDistributionElement>();

            //List<IfcRoot> ifcRoot = project.Extract<IfcRoot>();

            foreach (IfcSpatialElement ifcElement in ifcSpatialElement)  //ifcmesh
            {
                Entity eyeElement = null;

                Transformation elementTrs = new Transformation(1);

                if (ifcElement.Placement != null)
                {
                    elementTrs = Conversion.getPlacementTransformtion(ifcElement.Placement);
                }
                if (ifcElement.Representation != null)
                {
                    eyeElement = Conversion.getEntityFromIfcProductRepresentation(ifcElement.Representation, viewportLayout1, elementTrs);
                }
                if (eyeElement != null)
                {
                    eyeElement.TransformBy(elementTrs);

                    if (eyeElement is BlockReference)
                    {
                        UtilityIfc.loadProperties((IfcBlockReference)eyeElement, ifcElement);
                    }
                    else
                    {
                        IfcMesh ifcMesh;

                        Mesh eyeElementMesh;

                        if (eyeElement is Solid)
                        {
                            Solid eyeElementSolid = (Solid)eyeElement;

                            eyeElementMesh = eyeElementSolid.ConvertToMesh();
                        }
                        else
                        {
                            eyeElementMesh = (Mesh)eyeElement;
                        }
                        Color           color = eyeElementMesh.Color;
                        colorMethodType cmt   = eyeElementMesh.ColorMethod;

                        ifcMesh = new IfcMesh(eyeElementMesh.Vertices, eyeElementMesh.Triangles);

                        ifcMesh.Color       = color;
                        ifcMesh.ColorMethod = cmt;

                        UtilityIfc.loadProperties(ifcMesh, ifcElement);

                        eyeElement = ifcMesh;
                    }
                    viewportLayout1.Entities.Add(eyeElement, spatialLayer);
                }
            }

            foreach (IfcBuildingElement ifcElement in ifcBuildingElement)
            {
                if (ifcElement.GlobalId.StartsWith("3LHl4aR6j6bfwjDqKa2Mh9") && /**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            foreach (IfcDistributionElement ifcElement in ifcDistributionElement)
            {
                if (/*ifcElement.GlobalId.StartsWith("2O_tcxRRn1gegwp_L0mkmi") &&/**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            debug += Conversion.Debug;

            Debug.WriteLine(debug);

            TreeViewManager.PopulateTree(modelTree, viewportLayout1.Entities.ToList(), viewportLayout1.Blocks);

            viewportLayout1.ZoomFit();
        }