Beispiel #1
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            db.Factory.Options.GenerateOwnerHistory = false;
            IfcProjectLibrary context = new IfcProjectLibrary(db, "ObjectLibrary", IfcUnitAssignment.Length.Millimetre);

            IfcFootingType parametricType = generate(db, true, 800, 800, 300);

            IfcFootingType footingType1 = generate(db, false, 800, 800, 300);
            IfcFootingType footingType2 = generate(db, false, 600, 600, 250);
            IfcFootingType footingType3 = generate(db, false, 400, 400, 200);

            new IfcRelAssignsToProduct(new List <IfcObjectDefinition>()
            {
                footingType1, footingType2, footingType3
            }, parametricType);
            new IfcRelDeclares(context, new List <IfcDefinitionSelect>()
            {
                footingType1, footingType2, footingType3
            });
            DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            di = Directory.GetParent(di.FullName);
            db.WriteFile(Path.Combine(di.FullName, "ParametricFooting.ifc"));
            db.WriteFile(Path.Combine(di.FullName, "ParametricFooting.ifcxml"));
            db.WriteFile(Path.Combine(di.FullName, "ParametricFooting.ifcjson"));
        }
        //Demonstration of approach to filter out fire rated walls into seperate IFC file
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(args[0]);

            DuplicateOptions duplicateOptions = new DuplicateOptions(db.Tolerance);

            duplicateOptions.DuplicateDownstream = false;
            DatabaseIfc filteredDb = new DatabaseIfc(db);
            IfcProject  project    = filteredDb.Factory.Duplicate(db.Project, duplicateOptions) as IfcProject;

            duplicateOptions.DuplicateDownstream = true;

            List <IfcWall> walls = db.Project.Extract <IfcWall>();

            foreach (IfcWall wall in walls)
            {
                IfcPropertySingleValue property = wall.FindProperty("FireRating", true) as IfcPropertySingleValue;
                if (property != null && property.NominalValue != null)
                {
                    string value = property.NominalValue.ValueString.Trim();
                    if (value != "0")
                    {
                        filteredDb.Factory.Duplicate(wall, duplicateOptions);
                    }
                }
            }

            filteredDb.WriteFile(args[1]);
        }
Beispiel #3
0
    public static DatabaseIfc CreateDBCopy(DatabaseIfc copy)
    {
        string tempFileName = Directory.GetCurrentDirectory() + "\\_copy.ifc";

        copy.WriteFile(tempFileName);
        DatabaseIfc newModel = new DatabaseIfc(tempFileName);

        return(newModel);
    }
        static void Main(string[] args)
        {
            var dbInitial = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            dbInitial.Factory.Options.GenerateOwnerHistory = false;

            var site = new IfcSite(dbInitial, "site")
            {
                Guid = new Guid("aa4019f8-2584-44a1-a132-c17dfff69c41")
            };
            var project = new IfcProject(dbInitial, "GeomRep")
            {
                Guid = new Guid("94d4ddac-9120-4fb9-bea0-7a414ee725d4")
            };

            new IfcRelAggregates(project, new List <IfcObjectDefinition>()
            {
                site
            })
            {
                Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
            };

            IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 2, 5, 1));
            IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);

            IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 14, 5, 1));
            IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);


            var profile1 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 4, 6);
            IfcExtrudedAreaSolid      extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
            IfcProductDefinitionShape shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

            var profile2 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 5, 8);
            IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 4.1);
            IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


            var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
            {
                Name = "Cuboid1",
                Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bbaa")
            };
            var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
            {
                Name = "Cuboid2",
                Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706727a")
            };


            dbInitial.WriteFile("cube_double.ifc");
        }
        static void Main(string[] args)
        {
            // create database
            var database = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            // create IfcSite instance
            var site = new IfcSite(database, "Site entity");

            // create top-most spatial structure element IfcProject, set units and assign facility to project
            var project = new IfcProject(site, "Project entity");

            database.WriteFile("spatial.ifc");
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            DatabaseIfc db       = new DatabaseIfc(ModelView.Ifc4DesignTransfer);
            IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
            {
            };
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
            };

            IfcMaterial material = new IfcMaterial(db, "Concrete");

            IfcStructuralAnalysisModel analysisModel = new IfcStructuralAnalysisModel(building, "Analysis Model", IfcAnalysisModelTypeEnum.LOADING_3D);
            double                   y      = -1309.6875;
            IfcCartesianPoint        point  = new IfcCartesianPoint(db, -3968.75, y, 3000.0);
            IfcPlane                 plane  = new IfcPlane(new IfcAxis2Placement3D(point, db.Factory.YAxisNegative, db.Factory.XAxis));
            List <IfcFaceBound>      bounds = new List <IfcFaceBound>();
            List <IfcCartesianPoint> points = new List <IfcCartesianPoint>();

            points.Add(point);
            points.Add(new IfcCartesianPoint(db, 3071.25, y, 3000.0));
            points.Add(new IfcCartesianPoint(db, 3071.25, y, 0.0));
            points.Add(new IfcCartesianPoint(db, -3968.75, y, 0.0));
            bounds.Add(new IfcFaceOuterBound(new IfcPolyloop(points), true));
            points.Clear();
            points.Add(new IfcCartesianPoint(db, 551.25, y, 1000.0));
            points.Add(new IfcCartesianPoint(db, -448.75, y, 1000.0));
            points.Add(new IfcCartesianPoint(db, -448.75, y, 2000.0));
            points.Add(new IfcCartesianPoint(db, 551.25, y, 2000.0));
            bounds.Add(new IfcFaceBound(new IfcPolyloop(points), true));
            IfcFaceSurface             face          = new IfcFaceSurface(bounds, plane, true);
            IfcStructuralSurfaceMember surfaceMember = new IfcStructuralSurfaceMember(analysisModel, face, material, 1, 200);
            DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            di = Directory.GetParent(di.FullName);
            db.WriteFile(Path.Combine(di.FullName, "surfaceMember.ifc"));
            db.WriteFile(Path.Combine(di.FullName, "surfaceMember.ifcxml"));
            db.WriteFile(Path.Combine(di.FullName, "surfaceMember.ifcjson"));
        }
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);

            db.Factory.Options.GenerateOwnerHistory = false;

            IfcProject        project        = new IfcProject(db, "DemoProject");
            IfcProjectLibrary projectLibrary = new IfcProjectLibrary(db, "ClassificationLibrary");

            project.AddDeclared(projectLibrary);

            IfcClassification classification = new IfcClassification(db, "MyClassification");

            new IfcRelAssociatesClassification(classification, projectLibrary);

            IfcClassificationReference buildingElements = new IfcClassificationReference(classification)
            {
                Identification = "100", Name = "BuildingElements"
            };
            IfcClassificationReference walls = new IfcClassificationReference(buildingElements)
            {
                Identification = "100.100", Name = "Walls"
            };
            IfcClassificationReference partionWalls = new IfcClassificationReference(walls)
            {
                Identification = "100.100.002", Name = "PartiionWalls"
            };

            IfcSimplePropertyTemplate simplePropertyTemplate = new IfcSimplePropertyTemplate(db, "IsExternal")
            {
                GlobalId = "3Yss80qXKHuO00025QrE$V", PrimaryMeasureType = "IfcBoolean"
            };
            IfcPropertySetTemplate psetTemplate = new IfcPropertySetTemplate("Pset_WallCommon", simplePropertyTemplate)
            {
                GlobalId = "2VWFE0qXKHuO00025QrE$V"
            };

            IfcPropertySingleValue psv  = new IfcPropertySingleValue(db, "IsExternal", new IfcBoolean(false));
            IfcPropertySet         pset = new IfcPropertySet("Pset_WallCommon", psv);

            new IfcRelDefinesByTemplate(pset, psetTemplate);

            new IfcRelAssociatesClassification(partionWalls, pset);

            DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            di = Directory.GetParent(di.FullName);
            db.WriteFile(Path.Combine(di.FullName, "TestClassification.ifc"));
        }
Beispiel #8
0
    public static void ExportModel(List <Obj> objs, string location)
    {
        DatabaseIfc db       = new DatabaseIfc();
        IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
        {
        };
        IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Metre)
        {
        };

        foreach (Obj o in objs)
        {
            o.Export(db);
        }
        db.WriteFile(location);
    }
Beispiel #9
0
        static void Generate(TypeIFC type, ReleaseVersion release, string path)
        {
            DatabaseIfc db       = new DatabaseIfc(true, release);
            IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
            {
            };
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
            };

            IfcRectangleProfileDef    rect      = new IfcRectangleProfileDef(db, "Rect", 1000, 500);
            IfcExtrudedAreaSolid      extrusion = new IfcExtrudedAreaSolid(rect, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcDirection(db, 0, 0, 1), 2000);
            IfcProductDefinitionShape rep       = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrusion));

            if (type == TypeIFC.Chiller)
            {
                IfcChiller chiller = new IfcChiller(building, null, rep, null)
                {
                    PredefinedType = IfcChillerTypeEnum.AIRCOOLED
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    chiller.RelatingType = new IfcChillerType(db, "MyChillerType", IfcChillerTypeEnum.AIRCOOLED);
                }
            }
            else if (type == TypeIFC.AirTerminal)
            {
                IfcAirTerminal terminal = new IfcAirTerminal(building, null, rep, null)
                {
                    PredefinedType = IfcAirTerminalTypeEnum.DIFFUSER
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    terminal.RelatingType = new IfcAirTerminalType(db, "MyAirTerminalType", IfcAirTerminalTypeEnum.DIFFUSER);
                }
            }
            else
            {
                IfcElectricDistributionPoint point = new IfcElectricDistributionPoint(building, null, rep, null)
                {
                    DistributionPointFunction = IfcElectricDistributionPointFunctionEnum.DISTRIBUTIONBOARD
                };
            }
            db.WriteFile(Path.Combine(path, type.ToString() + " " + release.ToString() + ".ifc"));
        }
        protected void WriteFile(DatabaseIfc database, string path)
        {
            string filePath = Path.Combine(path, this.GetType().Name + ".ifc");

            if (File.Exists(filePath))
            {
                string[]      newLines      = database.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                List <string> existingLines = new List <string>(File.ReadAllLines(filePath));
                existingLines.RemoveAll(x => string.IsNullOrEmpty(x));

                if (newLines.Length == existingLines.Count)
                {
                    bool identical = true;
                    int  icounter  = 0;
                    for (; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter];
                        if (s1.StartsWith("FILE_SCHEMA"))
                        {
                            break;
                        }
                    }
                    for (; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter], s2 = existingLines[icounter];
                        if (s1.StartsWith("/* time_stamp */ ") && s2.StartsWith("/* time_stamp */ "))
                        {
                            continue;
                        }
                        if (string.Compare(s1, s2, true) != 0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        return;
                    }
                }
            }
            database.WriteFile(filePath);
        }
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3);

            IfcRailway sydneyLightRail = new IfcRailway(db);

            sydneyLightRail.Name       = "Sydney Light Rail";
            sydneyLightRail.ObjectType = "Light Rail Complexes";

            IfcProject project = new IfcProject(sydneyLightRail, "", IfcUnitAssignment.Length.Metre);

            IfcClassification          uniclass2015       = new IfcClassification(db, "Uniclass2015");
            IfcClassificationReference lightRailComplexes = new IfcClassificationReference(uniclass2015);

            lightRailComplexes.Identification = "Co_80_50_45";
            lightRailComplexes.Name           = "Light Rail Complexes";

            lightRailComplexes.Associate(sydneyLightRail);

            IfcFacilityPartTypeSelect facilityPartTypeSelect = new IfcFacilityPartTypeSelect(IfcRailwayPartTypeEnum.USERDEFINED);
            IfcFacilityPart           cbdCorridor            = new IfcFacilityPart(sydneyLightRail, "CBD and SE Light Rail", facilityPartTypeSelect, IfcFacilityUsageEnum.LONGITUDINAL);

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "En_80_50_71", Name = "Railway Corridors"
            }.Associate(cbdCorridor);

            IfcSpace deStop = new IfcSpace(cbdCorridor, "DE Stop");

            deStop.PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
            deStop.ObjectType     = "Light Rail Stops";

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "SL_80_50_47", Name = "Light Rail Stops"
            }.Associate(deStop);

            IfcSpace platform1_2 = new IfcSpace(deStop, "Platform 1/2");

            IfcClassificationReference classificationTicketSystem = new IfcClassificationReference(uniclass2015)
            {
                Identification = "Ss_75_90_80", Name = "Ticketing Systems"
            };
            IfcSystem opal = new IfcSystem(sydneyLightRail, "Opal system");

            classificationTicketSystem.Associate(opal);

            IfcDistributionSystem platform1_2TicketSystem = new IfcDistributionSystem(platform1_2, "DE Stop Platform 1/2 Ticket System", IfcDistributionSystemEnum.USERDEFINED);

            opal.AddAggregated(platform1_2TicketSystem);
            classificationTicketSystem.Associate(platform1_2TicketSystem);

            IfcCommunicationsApplianceType opalTicketMachineType = new IfcCommunicationsApplianceType(db, "Opal Ticket Machine", IfcCommunicationsApplianceTypeEnum.USERDEFINED);

            new IfcClassificationReference(uniclass2015)
            {
                Identification = "Pr_75_75_27_80", Name = "Smart card readers and writers"
            }.Associate(opalTicketMachineType);
            project.AddDeclared(opalTicketMachineType);

            IfcLocalPlacement          ticketMachineLocalPlacement = null;
            IfcProductDefinitionShape  ticketMachineShape          = null;
            IfcCommunicationsAppliance ticketMachine = new IfcCommunicationsAppliance(platform1_2, ticketMachineLocalPlacement, ticketMachineShape, platform1_2TicketSystem);

            IfcPropertySingleValue dateCommissioned = new IfcPropertySingleValue(db, "Date Commissioned", new IfcDate(DateTime.Now));

            new IfcPropertySet("TfNSW_Asset", dateCommissioned);

            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.Filter = "IFC BIM Data (*.ifc,*.ifcxml,*.ifcjson,*.ifczip)|*.ifc;*.ifcxml;*.ifcjson;*.ifczip";;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.WriteFile(saveFileDialog.FileName);
            }
        }
        static void Main(string[] args)
        {
            var ut_name = "Alignment-TUMAdsk-1";

            var db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);

            db.Factory.Options.GenerateOwnerHistory = false;

            var site = new IfcSite(db, "site");

            var project = new IfcProject(db, ut_name)
            {
                Name        = ut_name,
                Description = "sample for a single horizontal line segment - geometry + semantic part"
            };

            new IfcRelAggregates(project, new List <IfcObjectDefinition>()
            {
                site
            });

            // alignment
            var alignment = new IfcAlignment(site);

            alignment.AddComment("Entry point for alignment container");

            var horiz = new IfcAlignmentHorizontal(alignment);

            horiz.AddComment("groups all horizontal segments using an IfcRelNests rel");

            var pt1 = new IfcCartesianPoint(db, 3, 1, 0);

            var semanticPartOfTheSegment = new IfcAlignmentHorizontalSegment(
                pt1,
                0,
                0,
                0,
                56.4,
                IfcAlignmentHorizontalSegmentTypeEnum.LINE);

            semanticPartOfTheSegment.AddComment("Semantic part of the line segment");

            var semanticSegment1 = new IfcAlignmentSegment(horiz, semanticPartOfTheSegment);

            semanticSegment1.AddComment("link semantic segment with horizontal alignment container");

            // build geometric part
            var line = new IfcLine(pt1, new IfcVector(new IfcDirection(db, 0, 0), 1));

            line.AddComment("line geometry");
            var curveSeg = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis1Placement(pt1), new IfcNonNegativeLengthMeasure(0), new IfcNonNegativeLengthMeasure(56.4), line);

            curveSeg.AddComment("Trim the entire line");

            var shapeRep = new IfcShapeRepresentation(curveSeg, ShapeRepresentationType.Curve2D);
            IfcProductDefinitionShape shape1 = new IfcProductDefinitionShape(shapeRep)
            {
                Name = "Horizontal alignment geom rep"
            };

            shape1.AddComment("link the geometric rep of a line to the representation of the horizontal segment");

            horiz.Representation = shape1;

            db.WriteFile(ut_name + ".ifc");
        }
Beispiel #13
0
        private static void Main(string[] args)
        {
            var database = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);

            database.Factory.ApplicationDeveloper = "Sebastian Esser";
            // turn owner history off
            database.Factory.Options.GenerateOwnerHistory = false;

            // basic setup
            var site    = new IfcSite(database, "SiteA");
            var project = new IfcProject(
                site,
                "SampleProject with a span annotation",
                IfcUnitAssignment.Length.Metre
                );

            // create an annotation
            var annotation = new IfcAnnotation(database)
            {
                Name = "DesignSpeed",
            };

            annotation.AddComment("Annotation item span-placed along the alignment");

            // link annotation with site
            var contained = new IfcRelContainedInSpatialStructure(site);

            contained.RelatedElements.Add(annotation);

            #region Alignment

            var alignment = new IfcAlignment(site)
            {
                Name = "Basic alignment with a single horizontal segment"
            };
            alignment.AddComment("Generate alignment representation");

            // semantic
            var horizSegment = new IfcAlignmentHorizontalSegment(
                new IfcCartesianPoint(database, 5, 10),
                0,
                0,
                0,
                200,
                IfcAlignmentHorizontalSegmentTypeEnum.LINE);

            // geometric representation of a single segment. It gets referenced by IfcCompositeCurve.segments and IfcAlignmentSegment.Representation
            var curveSegment = new IfcCurveSegment(
                IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 0)),
                new IfcParameterValue(0),
                new IfcParameterValue(200),
                null);


            var segments = new List <IfcSegment> {
                curveSegment
            };
            var compositeCurve = new IfcCompositeCurve(segments);

            var rep = new IfcShapeRepresentation(compositeCurve)
            {
                RepresentationIdentifier = "Axis",
                RepresentationType       = "Curve2D"
            };

            alignment.Representation = new IfcProductDefinitionShape(rep);
            alignment.Axis           = compositeCurve;

            // create an alignment horizontal instance that takes a list of horizontal segments
            var alignmentHorizontal = new IfcAlignmentHorizontal(database)
            {
                Segments = new LIST <IfcAlignmentHorizontalSegment>()
                {
                    horizSegment
                }
            };

            // link alignment and and its horizontal part semantically
            new IfcRelAggregates(alignment, alignmentHorizontal);

            // create a new alignmentSegment with then gets one curve segment as its geometric representation
            var alignmentSegment = new IfcAlignmentSegment(database);

            // link horizontal alignment with the recently created alignment segment
            new IfcRelNests(alignmentHorizontal, alignmentSegment); // sorted list -> IfcRelNests

            // connect geom representation to this segment
            alignmentSegment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(curveSegment));

            #endregion Alignment

            #region Annotation placement

            alignmentSegment.AddComment("Create placement for annotation");

            var axis2place = new IfcAxis2PlacementLinear(
                new IfcPointByDistanceExpression(25, compositeCurve),
                null,
                null);

            var linPlacement = new IfcLinearPlacement(axis2place);
            linPlacement.Distance      = new IfcPointByDistanceExpression(128, compositeCurve);
            annotation.ObjectPlacement = linPlacement;

            #endregion Annotation placement

            #region PSet

            //var lengthUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.NONE, IfcSIUnitName.METRE);

            var lengthDerivedUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.KILO, IfcSIUnitName.METRE);
            lengthDerivedUnit.AddComment("PSet setup");
            var timeBaseUnit    = new IfcSIUnit(database, IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NONE, IfcSIUnitName.SECOND);
            var timeDerivedUnit = new IfcConversionBasedUnit(IfcUnitEnum.TIMEUNIT, "hour", new IfcMeasureWithUnit(new IfcPositiveInteger(3600), timeBaseUnit));

            var ifcderivedunitelem1 = new IfcDerivedUnitElement(lengthDerivedUnit, 1);
            var ifcderivedunitelem2 = new IfcDerivedUnitElement(timeDerivedUnit, -1);
            var speedUnit           = new IfcDerivedUnit(
                new List <IfcDerivedUnitElement> {
                ifcderivedunitelem1, ifcderivedunitelem2
            },
                IfcDerivedUnitEnum.LINEARVELOCITYUNIT);

            var pSet = new IfcPropertySet(annotation, "PSET_SpeedData", new List <IfcProperty>
            {
                new IfcPropertySingleValue(database, "CargoSpeed", new IfcLinearVelocityMeasure(60), speedUnit),
                new IfcPropertySingleValue(database, "DesignSpeed", new IfcLinearVelocityMeasure(110), speedUnit)
            });

            #endregion PSet

            database.WriteFile("AlignmentWithSpanAnnotation.ifc");
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3_RC2);

            db.Factory.Options.AngleUnitsInRadians  = false;
            db.Factory.Options.GenerateOwnerHistory = false;
            IfcRailway railway = new IfcRailway(db)
            {
                Name = "Default Railway", GlobalId = "2Iw5TO8gL8cQQMnPMEy58o"
            };
            IfcProject project = new IfcProject(railway, "Default Project", IfcUnitAssignment.Length.Metre)
            {
                GlobalId = "2VgFtp_1zCO98zJG_O3kln"
            };

            db.Factory.Options.GenerateOwnerHistory = true;
            project.OwnerHistory = db.Factory.OwnerHistoryAdded;
            db.Factory.Options.GenerateOwnerHistory = false;

            IfcGeometricRepresentationSubContext axisSubContext = db.Factory.SubContext(IfcGeometricRepresentationSubContext.SubContextIdentifier.Axis);

            IfcAlignment alignment = new IfcAlignment(railway)
            {
                Name = "TfNSW Alignment", GlobalId = "1F78QPlVv6N9AnnF$LSkp$"
            };
            IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 0, 0, 0);

            //IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 1000, 2000, 3000);
            alignment.ObjectPlacement = new IfcLocalPlacement(new IfcAxis2Placement3D(alignmentOrigin));

            double            lineLength = 100;
            IfcCartesianPoint point1     = new IfcCartesianPoint(db, -lineLength, 0);
            IfcCartesianPoint point2     = new IfcCartesianPoint(db, 0, 0);

            double xc               = 99.89734;
            double radius           = 500;
            double transitionLength = 100;

            double d          = -0.75 * Math.Sqrt(3) * xc / radius;
            double ang1       = (Math.Acos(-0.75 * Math.Sqrt(3) * xc / radius) * 180 / Math.PI / 3) + 240;
            double thiRadians = Math.Asin(2 / Math.Sqrt(3) * Math.Cos(ang1 * Math.PI / 180));
            double thi        = thiRadians * 180 / Math.PI;

            double m  = Math.Tan(thiRadians) / (3 * xc * xc);
            double yc = m * Math.Pow(xc, 3);

            IfcCartesianPoint point3 = new IfcCartesianPoint(db, xc, yc);

            double            cx        = Math.Sin(thiRadians) * radius;
            double            cy        = Math.Cos(thiRadians) * radius;
            IfcCartesianPoint arcCentre = new IfcCartesianPoint(db, xc - cx, yc + cy);

            double arcLength = 100;
            double arcAngle  = arcLength / radius * 180 / Math.PI;

            List <IfcSegment> compositeSegments = new List <IfcSegment>();

            IfcLine xLine = new IfcLine(db.Factory.Origin2d, new IfcVector(new IfcDirection(db, 1, 0), 1));

            IfcAlignmentHorizontalSegment linearSegment = new IfcAlignmentHorizontalSegment(point1, 0, 0, 0, lineLength, IfcAlignmentHorizontalSegmentTypeEnum.LINE);
            IfcLine         line         = new IfcLine(point1, new IfcVector(db.Factory.XAxis, 1));
            IfcTrimmedCurve trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0, point1), new IfcTrimmingSelect(lineLength, point2), true, IfcTrimmingPreference.PARAMETER);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            List <double> coefficientsX = new List <double>()
            {
                0, 1, 0, 0, 0, -0.9 * m * m, 0, 0, 0, 5.175 * Math.Pow(m, 4), 0, 0, 0, -43.1948 * Math.Pow(m, 6), 0, 0, 0, 426.0564 * Math.Pow(m, 8)
            };
            List <double> coefficientsY = new List <double>()
            {
                0, 0, 0, m, 0, 0, 0, -2.7 * Math.Pow(m, 3), 0, 0, 0, 17.955 * Math.Pow(m, 5), 0, 0, 0, -158.258 * Math.Pow(m, 7), 0, 0, 0, 1604.338 * Math.Pow(m, 9)
            };
            IfcSeriesParameterCurve seriesParameterCurve = new IfcSeriesParameterCurve(db.Factory.Origin2dPlace, coefficientsX, coefficientsY);

            IfcAlignmentHorizontalSegment transitionSegment = new IfcAlignmentHorizontalSegment(point2, 0, 0, radius, transitionLength, IfcAlignmentHorizontalSegmentTypeEnum.CUBICSPIRAL);            // { ObjectType = "TfNSW" };

            trimmedCurve = new IfcTrimmedCurve(seriesParameterCurve, new IfcTrimmingSelect(0, point2), new IfcTrimmingSelect(transitionLength, point3), true, IfcTrimmingPreference.PARAMETER);
            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcAxis2Placement2D circlePlacement = new IfcAxis2Placement2D(arcCentre)
            {
                RefDirection = new IfcDirection(db, Math.Sin(thiRadians), -Math.Cos(thiRadians))
            };
            IfcCircle circle = new IfcCircle(circlePlacement, radius);

            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(0, point3), new IfcTrimmingSelect(arcLength / radius * 180 / Math.PI), true, IfcTrimmingPreference.PARAMETER);

            IfcAlignmentHorizontalSegment arcSegment = new IfcAlignmentHorizontalSegment(point3, thi, radius, radius, arcLength, IfcAlignmentHorizontalSegmentTypeEnum.CIRCULARARC);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcCompositeCurve alignmentCurve = new IfcCompositeCurve(compositeSegments);

            alignment.Axis = alignmentCurve;

            double startDist = -123;
            IfcAlignmentHorizontal alignmentHorizontal = new IfcAlignmentHorizontal(alignment, linearSegment, transitionSegment, arcSegment)
            {
                StartDistAlong = startDist,
            };

            alignmentHorizontal.GlobalId        = "0sEEGBFgr289x9s$R$T7N9";
            alignmentHorizontal.ObjectPlacement = alignment.ObjectPlacement;
            alignmentHorizontal.Representation  = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, alignmentCurve, ShapeRepresentationType.Curve2D));

            IfcAlignmentSegment alignmentSegment = new IfcAlignmentSegment(alignmentHorizontal, transitionSegment);

            alignmentSegment.GlobalId   = "2_crD$eoPDah_QvgsPhXF3";
            alignmentSegment.ObjectType = "TFNSW";
            new IfcPropertySet(alignmentSegment, "TfNSW_Transition", new IfcPropertySingleValue(db, "m", m));

            IfcPointByDistanceExpression verticalDistanceExpression = new IfcPointByDistanceExpression(0, alignmentCurve);
            double startHeight = 25;

            verticalDistanceExpression.OffsetVertical = startHeight;
            IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(db, startDist, lineLength + transitionLength + arcLength, startHeight, 0.01, IfcAlignmentVerticalSegmentTypeEnum.CONSTANTGRADIENT);

            IfcAlignmentVertical alignmentVertical = new IfcAlignmentVertical(alignment, verticalSegment);

            alignmentVertical.GlobalId = "2YR0TUxTv75RC2XxZVmlj8";

            //IfcLinearAxis2Placement verticalAxisPlacement = new IfcLinearAxis2Placement(verticalDistanceExpression);
            //IfcLinearPlacement verticalLinearPlacement = new IfcLinearPlacement(alignmentPlacement, verticalAxisPlacement);
            //alignmentVertical.ObjectPlacement = verticalLinearPlacement;

            //List<IfcCurveSegment> verticalSegments = new List<IfcCurveSegment>();
            //IfcLine linearGradient = new IfcLine(db.Factory.Origin, new IfcVector(new IfcDirection(db, 1, 0, 0.01), 1)); //not right and should it be xy or xz
            //IfcCurveSegment verticalCurveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis2Placement3D(db.Factory.Origin2d), 50, linearGradient);
            //verticalSegments.Add(verticalCurveSegment);
            //IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(alignmentVertical,
            //	verticalLinearPlacement, verticalCurveSegment, 0, 50, startHeight, 0.01,
            //	IfcAlignmentVerticalSegmentTypeEnum.LINE);

            //IfcGradientCurve gradientCurve = new IfcGradientCurve(horizontalCurve, verticalSegments);
            //alignment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, gradientCurve, ShapeRepresentationType.Curve3D));
            IfcPointByDistanceExpression distanceExpression = new IfcPointByDistanceExpression(150, alignmentCurve);

            distanceExpression.OffsetLateral = 5;
            IfcAxis2PlacementLinear   axis2PlacementLinear   = new IfcAxis2PlacementLinear(distanceExpression);
            IfcLinearPlacement        linearPlacement        = new IfcLinearPlacement(alignment.ObjectPlacement, axis2PlacementLinear);
            IfcExtrudedAreaSolid      extrudedAreaSolid      = new IfcExtrudedAreaSolid(new IfcRectangleProfileDef(db, "", 0.5, 0.5), 5);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            IfcPile pile = new IfcPile(railway, linearPlacement, productDefinitionShape);

            new IfcRelPositions(db, alignment, new List <IfcProduct>()
            {
                pile
            });

            // Conceptual 50m span Bridge from chainage -80
            distanceExpression   = new IfcPointByDistanceExpression(-80 - startDist, alignmentCurve);
            axis2PlacementLinear = new IfcAxis2PlacementLinear(distanceExpression);
            IfcCurveSegment curveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, axis2PlacementLinear, 50, alignmentCurve);

            productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, curveSegment, ShapeRepresentationType.Curve2D));
            IfcBridge bridge = new IfcBridge(railway, alignment.ObjectPlacement, productDefinitionShape);

            db.WriteFile(args[0]);
        }
        /// <summary>
        /// You can give the name of the TestCase -> to build only them
        /// </summary>
        /// <param name="args">Testcases to expoert</param>
        /// <help> Testcases: Spatial_simple\n
        /// Railway_spatial\n Spatial_01\nPlacement_Local"\nGeomRepresentation_01\n
        /// \nGeomRepresentation_02\nGeomRepresentation_03\nGeomRepresentation_04
        /// \nLocalPlacement_01\nLinearPlacement_02
        ///
        /// </help>
        static void Main(string[] args)
        {
            //Var declaration

            string folder       = "Unittest";
            var    testcasename = new List <string>();

            testcasename.Add("Spatial_simple");
            testcasename.Add("Railway_spatial");
            testcasename.Add("Spatial_01");
            testcasename.Add("Placement_Local");
            testcasename.Add("GeomRepresentation_01");
            testcasename.Add("GeomRepresentation_02");
            testcasename.Add("GeomRepresentation_03");
            testcasename.Add("GeomRepresentation_04");
            //testcasename.Add("GeomRepresentation_05");
            testcasename.Add("LocalPlacement_01");
            testcasename.Add("LinearPlacement_02");
            System.IO.Directory.CreateDirectory(".\\" + folder);


            //Help handling + single selection
            if (args.Length != 0)
            {
                //Help handling
                if (args.First().Equals("-?"))
                {
                    foreach (var i in testcasename)
                    {
                        Console.WriteLine(i);
                    }
                    return;
                }

                //Select only selected ones
                testcasename = new List <string>();
                foreach (var i in args)
                {
                    testcasename.Add(i);
                }
            }


            foreach (var proname in testcasename)
            {
                var db = new DatabaseIfc(ModelView.Ifc4NotAssigned);
                db.Factory.Options.GenerateOwnerHistory = false;

                var site = new IfcSite(db, "site")
                {
                    Guid = new Guid("aa4019f8-2584-44a1-a132-c17dfff69c41")
                };
                var project = new IfcProject(db, proname)
                {
                    Guid = new Guid("94d4ddac-9120-4fb9-bea0-7a414ee725d4")
                };

                new IfcRelAggregates(project, new List <IfcObjectDefinition>()
                {
                    site
                })
                {
                    Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
                };
                //Some placements
                IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 5, 1));
                IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);
                IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 10, 5, 1));
                IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);
                IfcAxis2Placement3D placement3       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 15, 3, 6));
                IfcLocalPlacement   objectPlacement3 = new IfcLocalPlacement(site.ObjectPlacement, placement3);
                IfcAxis2Placement3D placement4       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 5, 8, 3));
                IfcLocalPlacement   objectPlacement4 = new IfcLocalPlacement(site.ObjectPlacement, placement4);
                IfcAxis2Placement3D originaxis2place = new IfcAxis2Placement3D(db.Factory.Origin);
                IfcLocalPlacement   origionobjplace  = new IfcLocalPlacement(site.ObjectPlacement, originaxis2place);


                //Select the Testcases and fill them into the container
                switch (proname)
                {
                case "Spatial_simple":
                    //initial File
                    IfcBuilding building1 = new IfcBuilding(db, "building1")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42")
                    };
                    building1.ObjectPlacement = objectPlacement1;


                    IfcBuilding building2 = new IfcBuilding(db, "building2")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b441151337")
                    };
                    building2.ObjectPlacement = objectPlacement2;

                    //Write inital File
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //continue with the updated version


                    IfcBuilding building3 = new IfcBuilding(db, "building3")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    break;

                case "Railway_spatial":
                    //initial
                    IfcSpatialZone spazone1 = new IfcSpatialZone(db, "Spatialzone1")
                    {
                        Guid            = new Guid("42c7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcSpatialZone spazone2 = new IfcSpatialZone(db, "Spatialzone2")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcSpatialZone spazone3 = new IfcSpatialZone(db, "Spatialzone3")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4422-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    IfcSpatialZone spazone4 = new IfcSpatialZone(db, "Spatialzone4")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement4
                    };

                    break;

                case "Spatial_01":
                    //creating building and add parts to it
                    building1 = new IfcBuilding(db, "building1")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcBuildingStorey buildingsto1 = new IfcBuildingStorey(building1, "Level1", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };

                    building1.IsDecomposedBy.First().Guid = new Guid("42abcd22-1337-4875-4242-abcd41153531");

                    var profile1 = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    IfcExtrudedAreaSolid      extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    IfcProductDefinitionShape shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    IfcWall wall = new IfcWall(buildingsto1, objectPlacement3, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall.ContainedInStructure.Guid = new Guid("42c74222-1337-4875-4242-d3b44abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    IfcBuildingStorey buildingsto2 = new IfcBuildingStorey(building1, "Level2", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-bbbb41153531"),
                        ObjectPlacement = objectPlacement4
                    };
                    // Reassign Wall to Storey2
                    wall.ContainedInStructure.RelatingStructure = buildingsto2;

                    break;

                case "Placement_Local":
                    //Initial set
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    //Wall at origin
                    IfcWall wall2 = new IfcWall(site, origionobjplace, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-d3b44abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcAxis2Placement3D wallaxisplace = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 3, 0));
                    wall2.ObjectPlacement = new IfcLocalPlacement(site.ObjectPlacement, wallaxisplace);


                    break;

                case "GeomRepresentation_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    IfcRectangleProfileDef    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b44abcd531");

                    var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706abcd")
                    };
                    proxy2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-00004abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");
                    //Update


                    proxy2.Representation = shape1;
                    shape2.Dispose(true);     //Remove orphaned entries


                    break;

                case "GeomRepresentation_02":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9885-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    extrudedAreaSolid2.Depth = 3;
                    break;

                case "GeomRepresentation_03":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    profile1.Dispose(false);     // Remove profile
                    var profile3 = new IfcCircleProfileDef(db, "CylinderProfileDef", 4);
                    extrudedAreaSolid1.SweptArea = profile3;
                    proxy1.Name = "Cylinder_extrudedArea";



                    break;

                case "GeomRepresentation_04":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    var points = new List <IfcCartesianPoint>();
                    points.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    var polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points[0], points[1], points[2], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[5], points[1]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[7], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[4], points[5], points[6], points[7]));
                    polyloop.Add(new IfcPolyLoop(points[1], points[5], points[6], points[2]));
                    polyloop.Add(new IfcPolyLoop(points[3], points[7], points[6], points[2]));

                    var faceouter = new List <IfcFaceOuterBound>();
                    foreach (var i in polyloop)
                    {
                        faceouter.Add(new IfcFaceOuterBound(i, true));
                    }

                    var face = new List <IfcFace>();
                    foreach (var j in faceouter)
                    {
                        face.Add(new IfcFace(j));
                    }

                    var closedshell = new IfcClosedShell(face);
                    var brep        = new IfcFacetedBrep(closedshell);

                    shape2 = new IfcProductDefinitionShape(new IfcShapeRepresentation(brep));
                    proxy1.Representation = shape2;
                    break;

                case "GeomRepresentation_05":
                    var points1 = new List <IfcCartesianPoint>();
                    points1.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points1.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    var points2 = new List <IfcCartesianPoint>();
                    points2.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points1));
                    polyloop.Add(new IfcPolyLoop(points2));


                    break;


                case "LocalPlacement_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9825-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab242-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    var point1 = new IfcCartesianPoint(db, 2, 2, 2);
                    placement1.Location = point1;


                    break;

                case "LinearPlacement_02":

                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    IfcLine line1 = new IfcLine(new IfcCartesianPoint(db, 1, 1, 1)
                                                , new IfcVector(new IfcDirection(db, 1, 1), 20));

                    IfcLine line2 = new IfcLine(new IfcCartesianPoint(db, 1, -1, -1)
                                                , new IfcVector(new IfcDirection(db, -1, 1), 20));

                    var alignment1 = new IfcAlignment(site, line1)
                    {
                        Name = "Alignment1",
                        Guid = new Guid("fbcba4b2-1cdd-48d5-88bb-d3aced15bbaa")
                    };
                    var alignment2 = new IfcAlignment(site, line2)
                    {
                        Name = "Alignment2",
                        Guid = new Guid("f111a4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };

                    var distn1 = new IfcPointByDistanceExpression(4, line1);
                    var distn2 = new IfcPointByDistanceExpression(2, line2);

                    //Deprecated but should be right for IFC4
                    var linearplace1 = new IfcLinearPlacement(line1, distn1)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.5, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.5))
                    };
                    var linearplace2 = new IfcLinearPlacement(line2, distn2)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.75, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.66))
                    };

                    proxy1 = new IfcBuildingElementProxy(site, linearplace1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000cc222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, linearplace2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-98a5-0f8ccd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ccc42-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    IfcLine line3 = new IfcLine(new IfcCartesianPoint(db, 0, 1, 0)
                                                , new IfcVector(new IfcDirection(db, 0, 5, 2), 15));
                    var distn3 = new IfcPointByDistanceExpression(4, line3);

                    linearplace1.PlacementMeasuredAlong = line3;
                    linearplace1.Distance = distn3;


                    break;


                default:
                    //exit
                    return;
                }

                db.WriteFile(".\\" + folder + "\\Update_" + proname + ".ifc");
                db.WriteXmlFile(".\\" + folder + "\\Update_" + proname + ".ifcxml");
            }
        }
Beispiel #16
0
        internal void GenerateExample(string path, ModelView modelView)
        {
            DatabaseIfc database = new DatabaseIfc(false, modelView);

            database.Factory.Options.GenerateOwnerHistory = false;
            database.NextObjectRecord = 10;
            IfcBuilding building = new IfcBuilding(database, "IfcBuilding")
            {
                GlobalId = "39t4Pu3nTC4ekXYRIHJB9W"
            };

            building.ContainsElements[0].GlobalId = "3Sa3dTJGn0H8TQIGiuGQd5";
            building.Comments.Add("defines the default building (as required as the minimum spatial element) ");
            database.NextObjectRecord = 20;
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
                GlobalId = "0$WU4A9R19$vKWO$AdOnKA"
            };

            project.IsDecomposedBy[0].GlobalId = "091a6ewbvCMQ2Vyiqspa7a";
            project.Comments.Add("general entities required for all IFC data sets, defining the context for the exchange");
            database.Factory.SubContext(FactoryIfc.SubContextIdentifier.Body);
            database.NextObjectRecord = 50;
            GenerateData(database, building);
            List <IfcRelDeclares> rds = project.Declares;

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            if (rds.Count > 0)
            {
                rds[0].GlobalId = "1Cjr05W9T0fx0M3_mdVqMd";
            }

            database[50].Comments.Add("Example data for " + this.GetType().Name);


            string filePath = Path.Combine(path, this.GetType().Name + ".ifc");

            if (File.Exists(filePath))
            {
                string[]      newLines      = database.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                List <string> existingLines = new List <string>(File.ReadAllLines(filePath));
                existingLines.RemoveAll(x => string.IsNullOrEmpty(x));

                if (newLines.Length == existingLines.Count)
                {
                    bool identical = true;
                    int  icounter  = 0;
                    for (; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter];
                        if (s1.StartsWith("FILE_SCHEMA"))
                        {
                            break;
                        }
                    }
                    for (; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter], s2 = existingLines[icounter];
                        if (s1.StartsWith("/* time_stamp */ ") && s2.StartsWith("/* time_stamp */ "))
                        {
                            continue;
                        }
                        if (string.Compare(s1, s2, true) != 0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        return;
                    }
                }
            }
            database.WriteFile(filePath);
        }
Beispiel #17
0
        internal static DatabaseIfc Generate(ModelView mdv, string path)
        {
            DatabaseIfc db = new DatabaseIfc(true, mdv);
            //IfcGeometricRepresentationContext
            //IfcCartesianPoint
            //IfcAxis2Placement3D
            //IfcDirection
            //IfcAxis2Placement2D
            //IfcSIUnit
            //IfcLocalPlacement
            IfcSite site = new IfcSite(db, "TestSite");
            //IfcPerson  NOT RV
            //IfcOrganization  NOT RV
            //IfcPersonAndOrganization  NOT RV
            //IfcOwnerHistory  NOT RV
            //fcApplication NOT RV
            //                     IfcProjectLibrary NOT RV Can't have multiple context
            IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre)
            {
            };
            //IfcUnitAssignment
            //IfcRelAggregates
            IfcBuilding building = new IfcBuilding(site, "TestBuilding")
            {
            };
            IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 3000);
            IfcSpace          space          = new IfcSpace(buildingStorey, null, null)
            {
                Name = "TestSpace"
            };

            space.RelatingType = new IfcSpaceType(db, "TestSpaceType", IfcSpaceTypeEnum.INTERNAL);

            IfcZone zone = new IfcZone(buildingStorey, "TestZone", "TestZoneLongName", new List <IfcSpace>()
            {
                space
            });

            IfcLocalPlacement localPlacement = buildingStorey.Placement as IfcLocalPlacement;

            IfcMaterial material = new IfcMaterial(db, "TestMaterial")
            {
                Description = "TestDescription", Category = "TestCategory"
            };
            IfcMaterialProperties materialProperties = new IfcMaterialProperties("TestMaterialProperties", material);

            materialProperties.AddProperty(new IfcPropertySingleValue(db, "MassDensity", new IfcMassDensityMeasure(1)));
            IfcSurfaceStyleShading surfaceStyleShading = new IfcSurfaceStyleShading(new IfcColourRgb(db, 1, 0, 0)
            {
                Name = "Red"
            });
            IfcSurfaceStyle surfaceStyle = new IfcSurfaceStyle(surfaceStyleShading, null, null, null, null);
            IfcMaterialDefinitionRepresentation materialDefinitionRepresentation = new IfcMaterialDefinitionRepresentation(new IfcStyledRepresentation(new IfcStyledItem(surfaceStyle)
            {
                Name = "TestStyledItem"
            }), material);

            IfcIndexedPolyCurve          indexedPolyCurve          = IPE200Curve(db);
            IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", indexedPolyCurve);
            IfcMaterialProfile           materialProfile           = new IfcMaterialProfile("TestMaterialProfile", material, arbitraryClosedProfileDef);
            IfcMaterialProfileSet        materialProfileSet        = new IfcMaterialProfileSet("TestMaterialProfileSet", materialProfile);

            IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 1, 0, 0), new IfcDirection(db, 0, 1, 0)), new IfcDirection(db, 0, 0, 1), 5000);
            IfcBeamType          beamType          = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM);

            beamType.MaterialSelect = materialProfileSet;
            IfcBeam beam = new IfcBeam(buildingStorey, new IfcLocalPlacement(localPlacement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 2000, 0))
            {
                RefDirection = new IfcDirection(db, 0, 1, 0)
            }), new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid)));

            //IfcGeometricRepresentationSubContext
            beam.RelatingType = beamType;
            //IfcRelDefinesByType

            //	if(mdv != ModelView.Ifc4Reference)
            //			IfcActorRole  NOT RV

            //IfcActuator
            //IfcActuatorType
            //IfcAdvancedBrep  NOT RV
            //IfcAdvancedFace   NOT RV
            //IfcAirTerminal
            //IfcAirTerminalBox
            //IfcAirTerminalBoxType
            //IfcAirTerminalType
            //IfcAirToAirHeatRecovery
            //IfcAirToAirHeatRecoveryType
            //IfcAlarm
            //IfcAlarmType
            //IfcArbitraryOpenProfileDef
            //IfcArbitraryProfileDefWithVoids
            //IfcAsymmetricIShapeProfileDef  NOT RV
            //IfcAudioVisualAppliance
            //IfcAudioVisualApplianceType
            //IfcAxis1Placement
            //IfcBeamStandardCase  NOT RV
            //IfcBlock   NOT RV
            //IfcBoiler
            //IfcBoilerType
            //IfcBooleanClippingResult  NOT RV
            //IfcBooleanResult  NOT RV
            //IfcBSplineCurveWithKnots  NOT RV
            //IfcBSplineSurface  NOT RV
            //IfcBSplineSurfaceWithKnots  NOT RV
            //IfcBuildingElementPart
            //IfcBuildingElementPartType
            //IfcBuildingElementProxy
            //IfcBuildingElementProxyType
            //IfcBuildingSystem
            //IfcBurner
            //IfcBurnerType
            //IfcCableCarrierFitting
            //IfcCableCarrierFittingType
            //IfcCableCarrierSegment
            //IfcCableCarrierSegmentType
            //IfcCableFitting
            //IfcCableFittingType
            //IfcCableSegment
            //IfcCableSegmentType
            //IfcCartesianPointList2D
            //IfcCartesianPointList3D
            //IfcCartesianTransformationOperator2D
            //IfcCartesianTransformationOperator2DnonUniform
            //IfcCartesianTransformationOperator3D
            //IfcCartesianTransformationOperator3DnonUniform
            //IfcCenterLineProfileDef
            //IfcChiller
            //IfcChillerType
            //IfcChimney
            //IfcChimneyType
            //IfcCircle
            //IfcCircleHollowProfileDef  NOT RV
            //IfcCircleProfileDef  NOT RV
            //IfcCivilElement
            //IfcCivilElementType
            //IfcClassification
            //IfcClassificationReference
            //IfcClosedShell
            //IfcCoil
            //IfcCoilType
            //IfcColourRgbList
            //IfcColourSpecification
            //IfcColumn
            //IfcColumnStandardCase  NOT RV
            //IfcColumnType
            //IfcCommunicationsAppliance
            //IfcCommunicationsApplianceType
            //IfcComplexProperty
            //IfcCompositeProfileDef  NOT RV
            //IfcCompressor
            //IfcCompressorType
            //IfcCondenser
            //IfcCondenserType
            //IfcConnectedFaceSet  NOT RV
            //IfcConnectionCurveGeometry  NOT RV
            //IfcConnectionVolumeGeometry  NOT RV
            //IfcController
            //IfcControllerType
            //IfcConversionBasedUnit
            //IfcConversionBasedUnitWithOffset
            //IfcCooledBeam
            //IfcCooledBeamType
            //IfcCoolingTower
            //IfcCoolingTowerType
            //IfcCovering
            //IfcCoveringType
            //IfcCsgSolid  NOT RV
            //IfcCShapeProfileDef  NOT RV
            //IfcCurtainWall
            //IfcCurtainWallType
            //IfcCurveStyle
            //IfcCurveStyleFont
            //IfcCurveStyleFontPattern
            //IfcDamper
            //IfcDamperType
            //IfcDerivedProfileDef  NOT RV
            //IfcDerivedUnit
            //IfcDerivedUnitElement
            //IfcDimensionalExponents
            //IfcDiscreteAccessory
            //IfcDiscreteAccessoryType
            //IfcDistributionChamberElement
            //IfcDistributionChamberElementType
            //IfcDistributionCircuit
            //IfcDistributionControlElement
            //IfcDistributionControlElementType
            //IfcDistributionElement
            //IfcDistributionElementType
            //IfcDistributionFlowElement
            //IfcDistributionFlowElementType
            //IfcDistributionPort
            //IfcDistributionSystem
            //IfcDocumentReference
            //IfcDoor
            //IfcDoorLiningProperties
            //IfcDoorPanelProperties
            //IfcDoorStandardCase  NOT RV
            //IfcDoorType
            //IfcDuctFitting
            //IfcDuctFittingType
            //IfcDuctSegment
            //IfcDuctSegmentType
            //IfcDuctSilencer
            //IfcDuctSilencerType
            //IfcEdge	 NOT RV
            //IfcEdgeCurve  NOT RV
            //IfcEdgeLoop  NOT RV
            //IfcElectricAppliance
            //IfcElectricApplianceType
            //IfcElectricDistributionBoard
            //IfcElectricDistributionBoardType
            //IfcElectricFlowStorageDevice
            //IfcElectricFlowStorageDeviceType
            //IfcElectricGenerator
            //IfcElectricGeneratorType
            //IfcElectricMotor
            //IfcElectricMotorType
            //IfcElectricTimeControl
            //IfcElectricTimeControlType
            //IfcElementAssembly
            //IfcElementAssemblyType
            //IfcElementComponent
            //IfcElementComponentType
            //IfcElementQuantity
            //IfcEllipseProfileDef  NOT RV
            //IfcEnergyConversionDevice
            //IfcEnergyConversionDeviceType
            //IfcEngine
            //IfcEngineType
            //IfcEvaporativeCooler
            //IfcEvaporativeCoolerType
            //IfcEvaporator
            //IfcEvaporatorType
            //IfcExtendedProperties
            //IfcExternalInformation
            //IfcExternalReference
            //IfcExtrudedAreaSolidTapered  NOT RV
            //IfcFace  NOT RV
            //IfcFaceBasedSurfaceModel  NOT RV
            //IfcFaceBound  NOT RV
            //IfcFaceOuterBound  NOT RV
            //IfcFaceSurface  NOT RV
            //IfcFacetedBrep  NOT RV
            //IfcFan
            //IfcFanType
            //IfcFastener
            //IfcFastenerType
            //IfcFeatureElement
            //IfcFeatureElementAddition  NOT RV
            //IfcFeatureElementSubtraction
            //IfcFillAreaStyle
            //IfcFillAreaStyleHatching
            //IfcFilter
            //IfcFilterType
            //IfcFireSuppressionTerminal
            //IfcFireSuppressionTerminalType
            //IfcFixedReferenceSweptAreaSolid  NOT RV
            //IfcFlowController
            //IfcFlowControllerType
            //IfcFlowFitting
            //IfcFlowFittingType
            //IfcFlowInstrument
            //IfcFlowInstrumentType
            //IfcFlowMeter
            //IfcFlowMeterType
            //IfcFlowMovingDevice
            //IfcFlowMovingDeviceType
            //IfcFlowSegment
            //IfcFlowSegmentType
            //IfcFlowStorageDevice
            //IfcFlowStorageDeviceType
            //IfcFlowTerminal
            //IfcFlowTerminalType
            //IfcFlowTreatmentDevice
            //IfcFlowTreatmentDeviceType
            //IfcFooting
            //IfcFootingType
            //IfcFurnishingElement
            //IfcFurnishingElementType
            //IfcFurniture
            //IfcFurnitureType
            //IfcGeographicElement
            //IfcGeographicElementType
            //IfcGeometricCurveSet
            //IfcGeometricSet
            //IfcGrid
            //IfcGridAxis
            //IfcGridPlacement  NOT RV
            //IfcGroup
            //IfcHalfSpaceSolid  NOT RV
            //IfcHeatExchanger
            //IfcHeatExchangerType
            //IfcHumidifier
            //IfcHumidifierType
            //IfcIndexedColourMap
            //IfcIndexedTextureMap
            //IfcIndexedTriangleTextureMap
            //IfcInterceptor
            //IfcInterceptorType
            //IfcIShapeProfileDef
            //IfcJunctionBox
            //IfcJunctionBoxType
            //IfcLamp
            //IfcLampType
            //IfcLibraryInformation  NOT RV
            //IfcLibraryReference  NOT RV
            //IfcLightFixture
            //IfcLightFixtureType
            //IfcLine
            //IfcLoop   NOT RV
            //IfcLShapeProfileDef  NOT RV
            //IfcMapConversion
            //IfcMappedItem
            //IfcMaterialConstituent
            //IfcMaterialConstituentSet
            //IfcMaterialLayer
            //IfcMaterialLayerSet
            //IfcMaterialLayerSetUsage  NOT RV
            //IfcMaterialLayerWithOffsets  NOT RV
            //IfcMaterialProfileSetUsage  NOT RV
            //IfcMaterialProfileSetUsageTapering  NOT RV
            //IfcMaterialProfileWithOffsets  NOT RV
            //IfcMaterialUsageDefinition  NOT RV
            //IfcMeasureWithUnit
            //IfcMechanicalFastener
            //IfcMechanicalFastenerType
            //IfcMedicalDevice
            //IfcMedicalDeviceType
            //IfcMember
            //IfcMemberStandardCase  NOT RV
            //IfcMemberType
            //IfcMonetaryUnit
            //IfcMotorConnection
            //IfcMotorConnectionType
            //IfcNamedUnit
            //IfcOpeningElement
            //IfcOpeningStandardCase  NOT RV
            //IfcOpenShell  NOT RV
            //IfcOrientedEdge  NOT RV
            //IfcOutlet
            //IfcOutletType
            //IfcPcurve  NOT RV
            //IfcPhysicalComplexQuantity
            //IfcPhysicalQuantity
            //IfcPhysicalSimpleQuantity
            //IfcPile
            //IfcPileType
            //IfcPipeFitting
            //IfcPipeFittingType
            //IfcPipeSegment
            //IfcPipeSegmentType
            //IfcPlane  NOT RV
            //IfcPlate
            //IfcPlateStandardCase  NOT RV
            //IfcPlateType
            //IfcPoint
            //IfcPolygonalBoundedHalfSpace  NOT RV
            //IfcPolyline  NOT RV
            //IfcPolyLoop  NOT RV
            //IfcPort
            //IfcPostalAddress
            //IfcPreDefinedPropertySet
            //IfcPresentationItem
            //IfcPresentationLayerAssignment
            //IfcPresentationStyle
            //IfcPresentationStyleAssignment
            //IfcProductDefinitionShape
            //IfcProductRepresentation
            //IfcProfileDef
            //IfcProfileProperties
            //IfcProjectedCRS
            //IfcProjectionElement  NOT RV
            //IfcProperty
            //IfcPropertyAbstraction
            //IfcPropertyBoundedValue
            //IfcPropertyDefinition
            //IfcPropertyEnumeratedValue
            //IfcPropertyEnumeration
            //IfcPropertyListValue
            //IfcPropertySet
            //IfcPropertySetTemplate  NOT RV
            //IfcPropertyTableValue
            //IfcPropertyTemplate  NOT RV
            //IfcPropertyTemplateDefinition  NOT RV
            //IfcProtectiveDevice
            //IfcProtectiveDeviceTrippingUnit
            //IfcProtectiveDeviceTrippingUnitType
            //IfcProtectiveDeviceType
            //IfcPump
            //IfcPumpType
            //IfcQuantityArea
            //IfcQuantityCount
            //IfcQuantityLength
            //IfcQuantitySet
            //IfcQuantityTime
            //IfcQuantityVolume
            //IfcQuantityWeight
            //IfcRailing
            //IfcRailingType
            //IfcRamp
            //IfcRampFlight
            //IfcRampFlightType
            //IfcRampType
            //IfcRectangleHollowProfileDef  NOT RV
            //IfcRectangleProfileDef  NOT RV
            //IfcRectangularPyramid  NOT RV
            //IfcReinforcingBar
            //IfcReinforcingBarType
            //IfcReinforcingElement
            //IfcReinforcingElementType
            //IfcReinforcingMesh
            //IfcReinforcingMeshType
            //IfcRelAssignsToGroup
            //IfcRelAssociatesClassification
            //IfcRelAssociatesDocument
            //IfcRelAssociatesLibrary  NOT RV
            //IfcRelAssociatesMaterial
            //IfcRelConnectsElements  NOT RV
            //IfcRelConnectsPathElements  NOT RV
            //IfcRelConnectsPorts
            //IfcRelConnectsWithRealizingElements  NOT RV
            //IfcRelContainedInSpatialStructure
            //IfcRelCoversBldgElements
            //IfcRelDeclares
            //IfcRelDefinesByProperties
            //IfcRelFillsElement
            //IfcRelFlowControlElements  NOT RV
            //IfcRelInterferesElements  NOT RV
            //IfcRelNests
            //IfcRelProjectsElement  NOT RV
            //IfcRelServicesBuildings
            //IfcRelVoidsElement
            //IfcRepresentation
            //IfcRepresentationContext
            //IfcRepresentationItem
            //IfcRepresentationMap
            //IfcRevolvedAreaSolid
            //IfcRevolvedAreaSolidTapered  NOT RV
            //IfcRightCircularCone  NOT RV
            //IfcRightCircularCylinder  NOT RV
            //IfcRoof
            //IfcRoofType
            //IfcRoundedRectangleProfileDef  NOT RV
            //IfcSanitaryTerminal
            //IfcSanitaryTerminalType
            //IfcSensor
            //IfcSensorType
            //IfcShadingDevice
            //IfcShadingDeviceType
            //IfcShapeRepresentation
            //IfcShellBasedSurfaceModel  NOT RV
            //IfcSimplePropertyTemplate  NOT RV
            //IfcSlab
            //IfcSlabElementedCase  NOT RV
            //IfcSlabStandardCase  NOT RV
            //IfcSlabType
            //IfcSolarDevice
            //IfcSolarDeviceType
            //IfcSpaceHeater
            //IfcSpaceHeaterType
            //IfcSpatialZone
            //IfcSpatialZoneType
            //IfcSphere  NOT RV
            //IfcStackTerminal
            //IfcStackTerminalType
            //IfcStair
            //IfcStairFlight
            //IfcStairFlightType
            //IfcStairType
            //IfcStyleModel
            //IfcSurface  NOT RV
            //IfcSurfaceCurveSweptAreaSolid  NOT RV
            //IfcSurfaceOfLinearExtrusion  NOT RV
            //IfcSurfaceOfRevolution  NOT RV
            //IfcSurfaceStyleRendering
            //IfcSurfaceStyleWithTextures surfaceStyleWithTextures = new IfcSurfaceStyleWithTextures(new IfcImageTexture(db,true,true,""));
            //IfcSweptDiskSolid
            //IfcSwitchingDevice
            //IfcSwitchingDeviceType
            //IfcSystemFurnitureElement
            //IfcSystemFurnitureElementType
            //IfcTank
            //IfcTankType
            //IfcTelecomAddress  NOT RV
            //IfcTendon
            //IfcTendonAnchor
            //IfcTendonAnchorType
            //IfcTendonType
            //IfcTessellatedFaceSet
            //IfcTessellatedItem
            //IfcTextureCoordinate
            //IfcTextureVertexList
            //IfcTransformer
            //IfcTransformerType
            //IfcTransportElement
            //IfcTransportElementType
            //IfcTriangulatedFaceSet
            //IfcTrimmedCurve
            //IfcTShapeProfileDef  NOT RV
            //IfcTubeBundle
            //IfcTubeBundleType
            //IfcUnitaryControlElement
            //IfcUnitaryControlElementType
            //IfcUnitaryEquipment
            //IfcUnitaryEquipmentType
            //IfcUShapeProfileDef  NOT RV
            //IfcValve
            //IfcValveType
            //IfcVector
            //IfcVertex  NOT RV
            //IfcVertexPoint  NOT RV
            //IfcVibrationIsolator
            //IfcVibrationIsolatorType
            //IfcVirtualGridIntersection  NOT RV
            //IfcWall
            //IfcWallElementedCase  NOT RV
            //IfcWallStandardCase  NOT RV
            //IfcWallType
            //IfcWasteTerminal
            //IfcWasteTerminalType
            //IfcWindow
            //IfcWindowLiningProperties
            //IfcWindowPanelProperties
            //IfcWindowStandardCase  NOT RV
            //IfcWindowType
            //IfcZShapeProfileDef  NOT RV
            db.WriteFile(Path.Combine(path, mdv.ToString() + ".ifc"));
            return(db);
        }
        static void Main(string[] args)
        {
            //Sample Data https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en
            //http://creativecommons.org/licenses/by/3.0/au/
            // © State of Queensland(Department of Transport and Main Roads) 2016

            // Suggested enhancements to test :
            //		Nominate Status and Reference Number
            //		Add Geolocation
            //		Use linear placement for statum layers
            //		Capture Auger, Casing, Wash Boring and Core drilling extents
            //		Add stratum data Impact Strength, Defect Spacing, Additional Data and Test Results, Sample Tests

            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3);

            db.Factory.Options.AngleUnitsInRadians = false;

            IfcSite    site    = new IfcSite(db, "Coombabah Creek Abutment");
            IfcProject project = new IfcProject(site, "FG6280", IfcUnitAssignment.Length.Metre)
            {
                LongName = "Gold Coast Light Rail(GCLR) Stage 2"
            };

            project.Description = "http://creativecommons.org/licenses/by/3.0/au/ © State of Queensland(Department of Transport and Main Roads) 2016";

            IfcAxis2Placement3D placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0.99));
            IfcLocalPlacement   boreHolePlacement = new IfcLocalPlacement(site.ObjectPlacement, placement);
            IfcBorehole         borehole          = new IfcBorehole(site, boreHolePlacement, null);

            borehole.Name        = "BH-CC-01";
            borehole.Description = "Sample borehole data published at  https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en";

            Pset_BoreholeCommon pset_BoreholeCommon = new Pset_BoreholeCommon(borehole);

            pset_BoreholeCommon.GroundwaterDepth = -5;             //Not identified in borehole log
            //new Pset_Uncertainty(borehole) { Basis = PEnum_UncertaintyBasis.MEASUREMENT };
            Pset_GeotechnicalAssemblyCommon psetGeotechnicalAssemblyCommon = new Pset_GeotechnicalAssemblyCommon(borehole);

            psetGeotechnicalAssemblyCommon.Purpose = PEnum_StrataAssemblyPurpose.GEOLOGICAL;

            //Should some of these properties be standard?
            //Should actors such as drilling company be IfcActor etc

            List <IfcProperty> tmrBoreholeProperties = new List <IfcProperty>();

            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Driller", new IfcIdentifier("North Coast Drilling")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "LoggedBy", new IfcIdentifier("D.Colborne/J.Armstrong")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "ReviewedBy", new IfcIdentifier("S.Foley")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Plunge", new IfcPlaneAngleMeasure(90)));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Started", new IfcDate(new DateTime(2015, 09, 10))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Completed", new IfcDate(new DateTime(2015, 09, 11))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Reference No", new IfcIdentifier("H12327")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Job No", new IfcIdentifier("498/04375")));
            new IfcPropertySet(borehole, "TMR_Borehole", tmrBoreholeProperties);

            IfcCircleProfileDef boreProfile = new IfcCircleProfileDef(db, "BoreHole", 0.05);

            IfcMaterial siltyClayTopsoil = new IfcMaterial(db, "Silty Clay (TopSoil)");

            siltyClayTopsoil.Description = "Dark grey, moist.";

            placement = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -0.1));
            IfcLocalPlacement         localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            IfcExtrudedAreaSolid      extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.1);
            IfcProductDefinitionShape shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));

            //gg Toolkit uses nesting rather than aggregating for stratums
            IfcSolidStratum solidStratum = new IfcSolidStratum(borehole, localPlacement, shape);

            solidStratum.SetMaterial(siltyClayTopsoil);

            IfcClassification soilClassification = new IfcClassification(db, "Soil Descriptions");

            soilClassification.Description = "Description and Classification of Soils for Geotechnical Purposes: Refer to AS1726 - 1993(Appendix A).";

            IfcMaterial siltyClayEstuarine = new IfcMaterial(db, "Silty CLAY (Estuarine)");

            siltyClayEstuarine.Description = "Dark grey, moist, soft.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -1.2));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 1.1);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(siltyClayEstuarine);
            IfcClassificationReference soilClassificationCI = new IfcClassificationReference(soilClassification)
            {
                Identification = "CI",
                Description    = "Inorganic clays of low to medium plasticity, gravelly clays, sandy clays, silty clays, lean clays"
            };

            soilClassificationCI.Associate(solidStratum);
#warning Should soil classification be assigned to soil or to stratum?

            IfcMaterial clayeySANDEstuarine = new IfcMaterial(db, "Clayey SAND (Estuarine)");
            clayeySANDEstuarine.Description = "Dark grey, wet, very loose.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.4));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.2);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(clayeySANDEstuarine);
            solidStratum.Description = "Fine to medium grained. Shell fragments throughout.";

            IfcClassificationReference soilClassificationSC = new IfcClassificationReference(soilClassification)
            {
                Identification = "SC",
                Description    = "Clayey sands, sandclay mixtures"
            };
            soilClassificationSC.Associate(solidStratum);

            IfcMaterial METAGREYWACKEdcf = new IfcMaterial(db, "METAGREYWACKE (DCf)");

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.8));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.4);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "XW: Recovered as orange brown to grey, moist, very stiff, Silty CLAY.";

            IfcClassification rockClassification = new IfcClassification(db, "Rock Descriptions");
            rockClassification.Description = "Refer to AS1726-1993 (Appendix A3.3) for the description and classification of rock material composition";


            IfcClassificationReference rockClassificationXW = new IfcClassificationReference(rockClassification)
            {
                Identification = "XW",
                Description    = "Rock is weathered to such an extent that it has 'soil' properties, i.e. it either disintegrates or can be remoulded in water, but substance fabric and rock structure still recognisable."
            };
            rockClassificationXW.Associate(solidStratum);

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -12.7));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.9);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "SW: Dark grey, fine to medium grained, indistinctly foliated, high to very high strength.";
            IfcClassificationReference rockClassificationSW = new IfcClassificationReference(rockClassification)
            {
                Identification = "SW",
                Description    = "Rock is slightly discoloured but shows little or no change of strength from fresh rock."
            };
            rockClassificationSW.Associate(solidStratum);


            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.Filter = "IFC BIM Data (*.ifc,*.ifcxml,*.ifcjson,*.ifczip)|*.ifc;*.ifcxml;*.ifcjson;*.ifczip";;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.WriteFile(saveFileDialog.FileName);
            }
        }
Beispiel #19
0
        public static int Main(string[] args)
        {
            var returnMessage      = (int)ExitCode.Success;
            var outputElements     = new List <JsonIfcElement>();
            var pathSource         = string.Empty;
            var pathDest           = string.Empty;
            var activeComptactJson = true;
            var readVersion        = false;
            var activeFullJson     = false;
            //var SCALE = 1.0;
            var context = new JsonConversionContext();
            JsonProjectIfcElement newProject = null;

            try
            {
                foreach (string arg in args)
                {
                    if (arg.ToLower().Trim() == "--version")
                    {
                        readVersion = true;
                    }
                    if (arg.ToLower().Trim() == "--indented")
                    {
                        activeComptactJson = false;
                    }
                    if (arg.ToLower().Trim() == "--full")
                    {
                        activeFullJson = true;
                    }
                    if (arg.Substring(0, 2) != "--" && pathSource != string.Empty && pathDest == string.Empty)
                    {
                        pathDest = arg;
                    }
                    if (arg.Substring(0, 2) != "--" && pathSource == string.Empty)
                    {
                        pathSource = arg;
                    }
                }

                if (readVersion)
                {
                    var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    Console.WriteLine($"1. ConvertIfc2Json : {version}{Environment.NewLine}(.Net version {typeof(string).Assembly.ImageRuntimeVersion})");
                    return(returnMessage);
                }



                if (File.Exists(pathSource))
                {
                    if (pathDest == string.Empty)
                    {
                        pathDest = pathSource + ".json";
                    }
                    var        db = new DatabaseIfc();
                    IfcProject project;
                    var        projectId = "";
                    var        sites     = new List <IfcSite>();
                    var        buildings = new List <IfcBuilding>();

                    try
                    {
                        db      = new DatabaseIfc(pathSource);
                        project = db.Project;
                        sites   = project.Extract <IfcSite>();



                        // IFC Project
                        try
                        {
                            if (project.GlobalId != null)
                            {
                                // REVIEW ne semble pas servir
                                //foreach (var unit in project.UnitsInContext.Units)
                                //{
                                //    var u = project.UnitsInContext.Extract<IfcSIUnit>();
                                //    // Console.WriteLine("2." + unit.StepClassName);
                                //}

                                // Computing the json conversion scale from current Geogym project
                                context.SCALE = project.GetJsonConversionScale();
                                projectId     = project.GlobalId;
                            }

                            outputElements.Add(newProject = new JsonProjectIfcElement(project));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("3. Element read error " + ex.Message);
                            returnMessage = (int)ExitCode.UnknownError;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("31. Write file : " + ex.Message);
                        returnMessage = (int)ExitCode.InvalidFile;
                    }

                    // IFC Site
                    foreach (var site in sites)
                    {
                        try
                        {
                            if (site.GlobalId != null)
                            {
                                var newSite = new JsonSiteIfcElement(site, newProject, context);
                                outputElements.Add(newSite);

                                // IFC Building
                                buildings = site.Extract <IfcBuilding>();
                                foreach (var building in buildings)
                                {
                                    var newBuildind = new JsonBuildingIfcElement(building, newSite, context); // REVIEW shouldn't create this unused instance if global id is null
                                    if (building.GlobalId != null)
                                    {
                                        outputElements.Add(newBuildind);
                                    }

                                    // IFC Building Storey // Levels
                                    var buildingStoreys = building.Extract <IfcBuildingStorey>();
                                    foreach (var buildingStorey in buildingStoreys)
                                    {
                                        var storeyElement = new JsonStoreyIfcElement(buildingStorey, newBuildind, context);
                                        outputElements.Add(storeyElement);


                                        // IFC Space // Rooms
                                        var spaces = buildingStorey.Extract <IfcSpace>();

                                        // Check IfcProduct Ids
                                        var productsIds    = new List <string>();
                                        var productCounter = 0;

                                        // IfcProduct
                                        var products = buildingStorey.Extract <IfcProduct>();
                                        foreach (var product in products)
                                        {
                                            try
                                            {
                                                if (product.GlobalId != null)
                                                {
                                                    var newElementProd = new JsonProductIfcElement(product, storeyElement, context);
                                                    var spaceCounter   = 0;

                                                    // Link to the Space
                                                    foreach (var space in spaces)
                                                    {
                                                        try
                                                        {
                                                            // REVIEW = LatestOrDefault
                                                            // IfcSpace
                                                            if (space.GlobalId == product.GlobalId)
                                                            {
                                                                try
                                                                {
                                                                    newElementProd.userData.name = space.LongName;
                                                                }
                                                                catch (NotSupportedException exEncode)
                                                                {
                                                                    newElementProd.userData.name = space.Name;
                                                                    Console.WriteLine("15. Space Name read error (id: " + space.GlobalId + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding;
                                                                }
                                                                catch (System.Exception ex)
                                                                {
                                                                    Console.WriteLine("29. Space Name LongName read error" + ex.Message);
                                                                }

                                                                newElementProd.userData.pset.Add("number", space.Name);

                                                                // Create boundary
                                                                geoGeometry geom = new geoGeometry();
                                                                IList <IList <IList <double> > > coords = new List <IList <IList <double> > >();
                                                                Dictionary <string, string>      props  = new Dictionary <string, string>();
                                                                string height    = "0.0";
                                                                string elevation = "0.0";


                                                                // Representation
                                                                if (space.Representation.Representations.Count > 0)
                                                                {
                                                                    foreach (IfcRepresentationItem item in space.Representation.Representations[0].Items)
                                                                    {
                                                                        try
                                                                        {
                                                                            if (item.StepClassName == "IfcExtrudedAreaSolid")
                                                                            {
                                                                                IfcExtrudedAreaSolid areaSolid = item as IfcExtrudedAreaSolid;
                                                                                IfcAxis2Placement3D  pos       = areaSolid.Position;
                                                                                Point3D loc = new Point3D(pos.Location.Coordinates[0], pos.Location.Coordinates[1], pos.Location.Coordinates[2]);
                                                                                height    = (areaSolid.Depth / context.SCALE).ToString();
                                                                                elevation = (buildingStorey.Elevation / context.SCALE).ToString();

                                                                                if (areaSolid.SweptArea.StepClassName == "IfcArbitraryClosedProfileDef")
                                                                                { // Polyline
                                                                                    IfcArbitraryClosedProfileDef arbitraryClosedProfiles = areaSolid.SweptArea as IfcArbitraryClosedProfileDef;
                                                                                    IList <IList <double> >      polyExt = new List <IList <double> >();

                                                                                    if (arbitraryClosedProfiles.OuterCurve.StepClassName == "IfcIndexedPolyCurve")
                                                                                    {
                                                                                        IfcIndexedPolyCurve     outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve;
                                                                                        IfcCartesianPointList2D points     = outerCurve.Points as IfcCartesianPointList2D;
                                                                                        foreach (double[] pts in points.CoordList)
                                                                                        {
                                                                                            if (pts.Length >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    xy.Add(pts[0] / context.SCALE);
                                                                                                    xy.Add(pts[1] / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("6." + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        List <IfcPolyline> poly = arbitraryClosedProfiles.OuterCurve.Extract <IfcPolyline>();

                                                                                        if (poly.Count > 0 && poly[0].Points.Count > 0)
                                                                                        {
                                                                                            foreach (IfcCartesianPoint pt in poly[0].Points)
                                                                                            {
                                                                                                if (pt.Coordinates.Count >= 2)
                                                                                                {
                                                                                                    try
                                                                                                    {
                                                                                                        IList <double> xy = new List <double>();
                                                                                                        xy.Add(pt.Coordinates[0] / context.SCALE);
                                                                                                        xy.Add(pt.Coordinates[1] / context.SCALE);
                                                                                                        polyExt.Add(xy);
                                                                                                    }
                                                                                                    catch (System.Exception exTransf)
                                                                                                    {
                                                                                                        Console.WriteLine("7. " + exTransf.Message);
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }


                                                                                    coords.Add(polyExt);

                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                    if (pos.RefDirection != null)
                                                                                    {
                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                    }
                                                                                    if (pos.Axis != null)
                                                                                    {
                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                    }
                                                                                }
                                                                                else if (areaSolid.SweptArea.StepClassName == "IfcRectangleProfileDef") // Rectangle
                                                                                {
                                                                                    List <IfcRectangleProfileDef> rectangleProfile = areaSolid.SweptArea.Extract <IfcRectangleProfileDef>();

                                                                                    if (rectangleProfile.Count > 0)
                                                                                    {
                                                                                        if (rectangleProfile[0].XDim > 0.0000001 && rectangleProfile[0].YDim > 0.0000001)
                                                                                        {
                                                                                            if (rectangleProfile[0].Position.Location.Coordinates.Count >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    Point3D lm   = new Point3D(0, 0, 0);
                                                                                                    double  XDim = rectangleProfile[0].XDim / 2;
                                                                                                    double  YDim = rectangleProfile[0].YDim / 2;

                                                                                                    // Left-Bottom
                                                                                                    IList <double> lb  = new List <double>();
                                                                                                    Point3D        lbP = new Point3D(lm.X - XDim, lm.Y - YDim, lm.Z);
                                                                                                    lb.Add(lbP.X / context.SCALE);
                                                                                                    lb.Add(lbP.Y / context.SCALE);
                                                                                                    // right-Bottom
                                                                                                    IList <double> rb  = new List <double>();
                                                                                                    Point3D        rbP = new Point3D(lm.X + XDim, lm.Y - YDim, lm.Z);
                                                                                                    rb.Add(rbP.X / context.SCALE);
                                                                                                    rb.Add(rbP.Y / context.SCALE);
                                                                                                    // right-top
                                                                                                    IList <double> rt  = new List <double>();
                                                                                                    Point3D        rtP = new Point3D(lm.X + XDim, lm.Y + YDim, lm.Z);
                                                                                                    rt.Add(rtP.X / context.SCALE);
                                                                                                    rt.Add(rtP.Y / context.SCALE);
                                                                                                    // left-top
                                                                                                    IList <double> lt  = new List <double>();
                                                                                                    Point3D        ltP = new Point3D(lm.X - XDim, lm.Y + YDim, lm.Z);
                                                                                                    lt.Add(ltP.X / context.SCALE);
                                                                                                    lt.Add(ltP.Y / context.SCALE);

                                                                                                    IList <IList <double> > polyExt = new List <IList <double> >();
                                                                                                    polyExt.Add(lb);
                                                                                                    polyExt.Add(rb);
                                                                                                    polyExt.Add(rt);
                                                                                                    polyExt.Add(lt);
                                                                                                    polyExt.Add(lb);
                                                                                                    coords.Add(polyExt);
                                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                                    if (pos.RefDirection != null)
                                                                                                    {
                                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                                    }
                                                                                                    if (pos.Axis != null)
                                                                                                    {
                                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                                    }
                                                                                                }
                                                                                                catch (System.Exception exMatrixTransf)
                                                                                                {
                                                                                                    Console.WriteLine("8. " + exMatrixTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                                else if (areaSolid.SweptArea.StepClassName == "IfcArbitraryProfileDefWithVoids") //
                                                                                {
                                                                                    // OuterCurve [IfcCurve]
                                                                                    IfcArbitraryProfileDefWithVoids arbitraryProfileDefWithVoids = areaSolid.SweptArea as IfcArbitraryProfileDefWithVoids;
                                                                                    IfcArbitraryClosedProfileDef    arbitraryClosedProfiles      = areaSolid.SweptArea as IfcArbitraryClosedProfileDef;
                                                                                    IList <IList <double> >         polyExt = new List <IList <double> >();

                                                                                    if (arbitraryProfileDefWithVoids.OuterCurve.StepClassName == "IfcIndexedPolyCurve")
                                                                                    {
                                                                                        IfcIndexedPolyCurve     outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve;
                                                                                        IfcCartesianPointList2D points     = outerCurve.Points as IfcCartesianPointList2D;
                                                                                        foreach (double[] pts in points.CoordList)
                                                                                        {
                                                                                            if (pts.Length >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    xy.Add(pts[0] / context.SCALE);
                                                                                                    xy.Add(pts[1] / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("9. " + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        List <IfcPolyline> poly = arbitraryProfileDefWithVoids.OuterCurve.Extract <IfcPolyline>();

                                                                                        foreach (IfcCartesianPoint pt in poly[0].Points)
                                                                                        {
                                                                                            if (pt.Coordinates.Count >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    Point3D        p  = new Point3D(pt.Coordinates[0], pt.Coordinates[1], 0);
                                                                                                    xy.Add(p.X / context.SCALE);
                                                                                                    xy.Add(p.Y / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("10. " + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                    coords.Add(polyExt);

                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                    if (pos.RefDirection != null)
                                                                                    {
                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                    }
                                                                                    if (pos.Axis != null)
                                                                                    {
                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                    }
                                                                                }
                                                                            }
                                                                            else if (item.StepClassName == "IfcFacetedBrep-XXX")  // TODO : Fix export 3D Object
                                                                            {                                                     // https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/schema/ifcgeometricmodelresource/lexical/ifcfacetedbrep.htm
                                                                                List <IfcFacetedBrep> facetedBreps = item.Extract <IfcFacetedBrep>();
                                                                                if (facetedBreps.Count > 0)
                                                                                {
                                                                                    IfcFacetedBrep facetedBrep = facetedBreps[0];
                                                                                    elevation = (buildingStorey.Elevation / context.SCALE).ToString();
                                                                                    if (facetedBrep.Outer.StepClassName == "IfcClosedShell")
                                                                                    {
                                                                                        if (facetedBrep.Outer.CfsFaces.Count > 0) //
                                                                                        {
                                                                                            // CfsFaces[].Bounds[IfcFaceBound].Bound.Polgon[IfcCartesianPoint].Coordinates[3]
                                                                                            // OuterCurve [IfcCurve]
                                                                                            foreach (IfcFace cfsFace in facetedBrep.Outer.CfsFaces)
                                                                                            {
                                                                                                foreach (IfcFaceBound faceBound in cfsFace.Bounds)
                                                                                                {
                                                                                                    IList <IList <double> > polyExt = new List <IList <double> >();
                                                                                                    if (faceBound.Bound.StepClassName == "IfcPolyLoop")
                                                                                                    {
                                                                                                        IfcPolyLoop polyLoop = faceBound.Bound as IfcPolyLoop;
                                                                                                        foreach (IfcCartesianPoint pt in polyLoop.Polygon)
                                                                                                        {
                                                                                                            IList <double> xy = new List <double>();
                                                                                                            xy.Add(pt.Coordinates[0] / context.SCALE); //+ loc.X);
                                                                                                            xy.Add(pt.Coordinates[1] / context.SCALE); // + loc.Y);
                                                                                                            xy.Add(pt.Coordinates[2] / context.SCALE); // + loc.YZ;
                                                                                                            polyExt.Add(xy);
                                                                                                        }
                                                                                                    }

                                                                                                    // ERREUR OBJET 3D
                                                                                                    // TODO : Fix export 3D Object
                                                                                                    // coords.Add(polyExt);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        catch (System.Exception exRepresentationItem)
                                                                        {
                                                                            Console.WriteLine("11. Element read error exRepresentationItem" + exRepresentationItem.Message);
                                                                            returnMessage = (int)ExitCode.UnknownError;
                                                                        }
                                                                    }
                                                                }

                                                                if (coords.Count == 0)
                                                                {
                                                                    // Console.WriteLine("12. " + coords.Count);
                                                                }

                                                                props.Add("height", height);
                                                                props.Add("elevation", elevation);

                                                                geom.type        = "Polygon";
                                                                geom.coordinates = coords;

                                                                newElementProd.boundary            = new geoFeature();
                                                                newElementProd.boundary.type       = "Feature";
                                                                newElementProd.boundary.id         = null;
                                                                newElementProd.boundary.properties = props;
                                                                newElementProd.boundary.geometry   = geom;
                                                            }
                                                            var builingElements = space.Extract <IfcBuildingElementProxy>();
                                                            // IFC Elements
                                                            foreach (var bElement in builingElements)
                                                            {
                                                                IfcRelContainedInSpatialStructure productIds = bElement.ContainedInStructure;
                                                                foreach (IfcProduct pId in productIds.RelatedElements)
                                                                {
                                                                    try
                                                                    {
                                                                        if (pId.GlobalId == product.GlobalId)
                                                                        {
                                                                            newElementProd.userData.spaceId = space.GlobalId;
                                                                        }
                                                                    }
                                                                    catch (System.Exception ex)
                                                                    {
                                                                        Console.WriteLine("13. Element read error" + ex.Message);
                                                                        returnMessage = (int)ExitCode.UnknownError;
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        catch (Exception ex)
                                                        {
                                                            Console.WriteLine("16. Element read error" + ex.Message);
                                                            returnMessage = (int)ExitCode.UnknownError;
                                                        }

                                                        spaceCounter += 1;
                                                    }

                                                    // Add to list
                                                    productsIds.Add(newElementProd.id);

                                                    if (newElementProd.userData.type != "IfcBuildingStorey")
                                                    {
                                                        outputElements.Add(newElementProd);
                                                    }
                                                    else
                                                    {
                                                        // Console.WriteLine("14. Error IfcBuildingStorey");
                                                    }
                                                }
                                            }
                                            catch (NotSupportedException exEncode)
                                            {
                                                Console.WriteLine("28. Name read error (product counter: " + productCounter + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding;
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("29. Element read error" + ex.Message);
                                                returnMessage = (int)ExitCode.UnknownError;
                                            }

                                            productCounter += 1;
                                        }



                                        // IFC Elements

                                        var elements = buildingStorey.Extract <IfcBuildingElementProxy>();
                                        foreach (IfcBuildingElementProxy element in elements
                                                 .Where(element => element.GlobalId != null && !productsIds.Contains(element.GlobalId)))
                                        {
                                            try
                                            {
                                                // Add to list
                                                outputElements.Add(new JsonBuildingElementProxyIfcElement(element, storeyElement, context));
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("17. Element read error" + ex.Message);
                                                returnMessage = (int)ExitCode.UnknownError;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("18. Element read error" + ex.Message);
                            returnMessage = (int)ExitCode.UnknownError;
                        }
                    }



                    // Json Settings
                    Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings {
                        NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
                    };

                    if (activeComptactJson)
                    {
                        if (activeFullJson)
                        {
                            // Original File
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(db.JSON(), Newtonsoft.Json.Formatting.None, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                        else
                        {
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.None, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                    }
                    else
                    {
                        if (activeFullJson)
                        {
                            // Original File
                            db.WriteFile(pathDest);
                        }
                        else
                        {
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.Indented, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                    }
                }
                else
                {
                    returnMessage = (int)ExitCode.InvalidFilename;
                }
            }
            catch (Exception ioEx)
            {
                Console.WriteLine("19. " + ioEx.Message);
                returnMessage = (int)ExitCode.InvalidFile;
            }

            Console.WriteLine("20. " + pathDest);
            return(returnMessage);
        }
        static void Main(string[] args)
        {
            // create database
            var database = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);

            // create IfcSite instance
            var site = new IfcSite(database, "sampleSite");

            // create top-most spatial structure element IfcProject, set units and assign facility to project
            var project = new IfcProject(site, "myProject", IfcUnitAssignment.Length.Metre);


            // -- create facility representing the logical unit of road-bridge-road --
            var trafficFacility = new IfcFacility(site, "TrafficWayA")
            {
                CompositionType = IfcElementCompositionEnum.COMPLEX
            };
            // create parts/child-facilities and assign them to the traffic way
            var facilityPart1 = new IfcFacilityPart(
                trafficFacility,
                "myRoadPart01",
                new IfcFacilityPartTypeSelect(
                    IfcRoadPartTypeEnum.ROADSEGMENT),
                IfcFacilityUsageEnum.LONGITUDINAL);

            facilityPart1.Description = "TrafficWayA -> Segment 1";

            var facilityPart2 = new IfcFacility(trafficFacility, "myBridge")
            {
                Description = "TrafficWayA -> Segment 2"
            };

            var facilityPart3 = new IfcFacilityPart(
                trafficFacility,
                "myRoadPart02",
                new IfcFacilityPartTypeSelect(
                    IfcRoadPartTypeEnum.ROADSEGMENT),
                IfcFacilityUsageEnum.LONGITUDINAL)
            {
                Description = "TrafficWayA -> Segment 3"
            };

            // -- river facility --
            var river = new IfcFacility(site, "River")
            {
                CompositionType = IfcElementCompositionEnum.NOTDEFINED
            };
            // add a part to the river
            var riverPart = new IfcFacilityPart(
                river,
                "myRiver",
                new IfcFacilityPartTypeSelect(
                    IfcMarinePartTypeEnum.WATERFIELD),
                IfcFacilityUsageEnum.LONGITUDINAL)
            {
                Description = "River that passes under the bridge"
            };

            // store the IFC model
            database.WriteFile("IFC4X3RC1_spatialDecomposition.ifc");
        }