Esempio n. 1
0
        public void BaseLoinCreationTest()
        {
            var editor = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "CAS",
                ApplicationFullName       = "LOIN Creator",
                ApplicationIdentifier     = "LOIN",
                ApplicationVersion        = "4.0",
                EditorsFamilyName         = "Santini Aichel",
                EditorsGivenName          = "Johann Blasius",
                EditorsOrganisationName   = "Independent Architecture"
            };

            using var loin = Model.Create(editor);
            using var txn  = loin.Internal.BeginTransaction("LOIN creation");

            var actor     = loin.CreateActor("Client", "Owner of the building");
            var milestone = loin.CreateMilestone("Preliminary design", "Preliminary design handover milestone");
            var reason    = loin.CreatePurpose("Handover", "Handover of data");
            var item      = loin.CreateBreakedownItem("Window", "E456.789.12", "Window is a building element used to controll light flow into the space");



            var width = loin.CreateSimplePropertyTemplate("Width", "Width of the window", nameof(IfcLengthMeasure));

            width.SetName("cs", "Šířka");
            width.SetDescription("cs", "Šířka okna");

            Assert.IsNotNull(width.GetName("cs"));
            Assert.IsNotNull(width.GetDescription("cs"));

            var height = loin.CreateSimplePropertyTemplate("Height", "Height of the window", nameof(IfcLengthMeasure));

            height.SetName("cs", "Výška");
            height.SetDescription("cs", "Výška okna");
            var code = loin.CreateSimplePropertyTemplate("BarCode", "Bar code of the window", nameof(IfcIdentifier));

            code.SetName("cs", "Čárový kód");
            code.SetDescription("cs", "Čárový kód okna");

            var requirement = loin.CreatePropertySetTemplate("FM Requirements", "Requirements for Facility Management");

            requirement.HasPropertyTemplates.Add(width);
            requirement.HasPropertyTemplates.Add(height);
            requirement.HasPropertyTemplates.Add(code);
            requirement.SetName("cs", "Požadavky pro FM");
            requirement.SetDescription("cs", "Požadavky pro správu a údržbu");

            var requirements = loin.CreateRequirementSet("Base requirements", "Base requirements for the window");

            requirements.Add(requirement);

            var geomReq = loin.CreateGeometryRequirements();

            geomReq.ID                  = Guid.NewGuid().ToString();
            geomReq.Name                = "Window geometry requirements";
            geomReq.Appearance          = "No textures";
            geomReq.Definition          = "Definition of the window geometry requirements";
            geomReq.Detailing           = Requirements.DetailingEnum.LowDetail;
            geomReq.Dimensionality      = Requirements.DimensionalityEnum.Dim_3D;
            geomReq.ParametricBehaviour = "not parametric";

            var context = new IContextEntity[] { actor, milestone, reason, item };

            foreach (var contextItem in context)
            {
                contextItem.AddToContext(requirements);
            }

            txn.Commit();

            // serialize as IFC
            loin.Save("LOIN.ifc");

            // serialize as XML
            loin.Save("LOIN.ifcXML");

            // validate IFC model
            var validator = new IfcValidator();
            var ok        = validator.Check(loin.Internal);

            Assert.IsTrue(ok);

            // get MVD
            var mvd = loin.GetMvd(XbimSchemaVersion.Ifc4, "en", "LOIN Representation", "Requirements defined using LOIN, represented as validation MVD", "LOIN", "Classification");

            // serialize MVD
            mvd.Save("LOIN.mvdXML");

            // validate MVD XML XSD
            var logger = Xbim.Common.XbimLogging.CreateLogger("MVDXML schema validation");
            var msg    = MvdValidator.ValidateXsd("LOIN.mvdXML", logger);

            Assert.IsTrue(string.IsNullOrWhiteSpace(msg));
        }
Esempio n. 2
0
        public void SampleCreationTest()
        {
            // details of the creator and the application
            var editor = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "TC442 WG2 TG1",
                ApplicationFullName       = "Level of Information Need Sample",
                ApplicationIdentifier     = "LOIN",
                ApplicationVersion        = "1.0",
                EditorsFamilyName         = "Cerny",
                EditorsGivenName          = "Martin",
                EditorsOrganisationName   = "Czech Standardization Agency"
            };

            // IFC wrapper model
            using var model = Model.Create(editor);
            using var txn   = model.Internal.BeginTransaction("Level of Information Need specification");
            var ifc = model.Internal.Instances;

            // root object to hold Level of Information Need requirements
            var requirements = model.CreateRequirementSet("LOIN-C Issued for Construction DP A", "Level of Information need - Issued for Construction for Architectural Design - Design Package A");

            // prerequisities
            var purpose         = model.CreatePurpose("Design review", "Review of detailed design information");
            var appointingParty = model.CreateActor("Design Lead", "Person responsible for the coordination of design disciplines");
            var appointedParty  = model.CreateActor("Archtect-Engineer (AE)", "Person providing joint architectural-engineering services");
            var milestone       = model.CreateMilestone("Design Package A", "First design package to be issued for construction");
            var item            = model.CreateBreakedownItem("Suspended ceiling", "2RBXAUzUb4jxhBy1TJPbpm", "a secondary ceiling, hung below the main ceiling");

            // assign requirements to prerequisities
            purpose.AddToContext(requirements);
            appointingParty.AddToContext(requirements, "APPOINTING_PARTY"); // actor in a role
            appointedParty.AddToContext(requirements, "APPOINTED_PARTY");   // actor in a role
            milestone.AddToContext(requirements);
            item.AddToContext(requirements);
            purpose.AddToContext(requirements);

            // geometry requirements
            var geomReq = model.CreateGeometryRequirements();

            geomReq.ID                  = Guid.NewGuid().ToString();
            geomReq.Name                = "Geometrical information issued for construction relative offset";
            geomReq.Definition          = "Geometrical information for objects with relative height offset; to be issued for construction";
            geomReq.Detailing           = Requirements.DetailingEnum.HighDetail;
            geomReq.Dimensionality      = Requirements.DimensionalityEnum.Dim_3D;
            geomReq.Appearance          = "No texture";
            geomReq.ParametricBehaviour = "parametric geometry";

            requirements.Add(geomReq);

            // aplha-numeric requirements
            var alphaNumericRequirements = model.CreatePropertySetTemplate("suspended ceiling characteristics", "Suspended ceiling characteristics necessary for commence of construction")
                                           .SetId("1bMoDf5wDDPRdm3Z3IBzbF");

            requirements.Add(alphaNumericRequirements);

            var thermalConductivity = model.CreateSimplePropertyTemplate("design thermal conductivity according to ISO 10456", null, nameof(IfcThermalConductivityMeasure))
                                      .SetId("0zqubcVzf7EB2eIHdprthv");

            alphaNumericRequirements.HasPropertyTemplates.Add(thermalConductivity);

            var loadOfMetal = model.CreateSimplePropertyTemplate("admissible load of metal suspension according to EN 13964", null, nameof(IfcForceMeasure), ifc.New <IfcSIUnit>(u => {
                u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.FORCEUNIT;
                u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.NEWTON;
            }))
                              .SetId("1gn5hadEL1ixoXBYdHALsC")
                              .SetConstraint(new IfcForceMeasure(900.0), Xbim.Ifc4.Interfaces.IfcBenchmarkEnum.GREATERTHAN);

            alphaNumericRequirements.HasPropertyTemplates.Add(loadOfMetal);

            var reactionToFire = model.CreateSimplePropertyTemplate("reaction to fire classification of substructure according to EN 13501-1", null, nameof(IfcIdentifier))
                                 .SetId("1ZVre0Sbz6RfbGBJD4Bnip")
                                 .SetConstraint(new IfcIdentifier("A1"), Xbim.Ifc4.Interfaces.IfcBenchmarkEnum.EQUALTO)
                                 .MakeEnumerated("reaction to fire classification", "A1", "A2", "A3", "A4", "A5");

            alphaNumericRequirements.HasPropertyTemplates.Add(reactionToFire);

            var manufacturer = model.CreateSimplePropertyTemplate("manufacturer", null, nameof(IfcIdentifier))
                               .SetId("3uaKQyxxj2gwHI3oQk3Sci");

            alphaNumericRequirements.HasPropertyTemplates.Add(manufacturer);


            // document requirements
            var documentRequirements = model.CreatePropertySetTemplate("Documentation for suspended ceilings - DPA", "Required Documentation for suspended ceilings at design package A");

            requirements.Add(documentRequirements);

            var installInstructions = model.CreateDocumentPropertyTemplate("Installation instruction", "Manufacturer's installation instruction");

            documentRequirements.HasPropertyTemplates.Add(installInstructions);

            var DoP = model.CreateDocumentPropertyTemplate("DoP", "Manufacturer's declaration of performance");

            documentRequirements.HasPropertyTemplates.Add(DoP);

            var ceilingDetail = model.CreateDocumentPropertyTemplate("Detail wall-ceiling", "Detail for the connection between the wall and the ceiling");

            documentRequirements.HasPropertyTemplates.Add(ceilingDetail);

            var expJoinDetail = model.CreateDocumentPropertyTemplate("Detail expansion joint", "Detail for expansion joint");

            documentRequirements.HasPropertyTemplates.Add(expJoinDetail);

            // commit changes
            txn.Commit();

            // serialize as IFC
            model.Save("LevelOfInformationNeed_Sample1.ifc");

            // serialize as IFC XML
            model.Save("LevelOfInformationNeed_Sample1.ifcXML");

            // validate IFC model
            var validator = new IfcValidator();
            var ok        = validator.Check(model.Internal);

            Assert.IsTrue(ok);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //
            ifcSIUnitMap = new Dictionary <string, IfcSIUnitName>
            {
                { "AMPERE", IfcSIUnitName.AMPERE },
                { "BECQUEREL", IfcSIUnitName.BECQUEREL },
                { "CANDELA", IfcSIUnitName.CANDELA },
                { "COULOMB", IfcSIUnitName.COULOMB },
                { "CUBIC_METRE", IfcSIUnitName.CUBIC_METRE },
                { "DEGREE_CELSIUS", IfcSIUnitName.DEGREE_CELSIUS },
                { "FARAD", IfcSIUnitName.FARAD },
                { "GRAM", IfcSIUnitName.GRAM },
                { "GRAY", IfcSIUnitName.GRAY },
                { "HENRY", IfcSIUnitName.HENRY },
                { "HERTZ", IfcSIUnitName.HERTZ },
                { "JOULE", IfcSIUnitName.JOULE },
                { "KELVIN", IfcSIUnitName.KELVIN },
                { "LUMEN", IfcSIUnitName.LUMEN },
                { "LUX", IfcSIUnitName.LUX },
                { "METRE", IfcSIUnitName.METRE },
                { "MOLE", IfcSIUnitName.MOLE },
                { "NEWTON", IfcSIUnitName.NEWTON },
                { "OHM", IfcSIUnitName.OHM },
                { "PASCAL", IfcSIUnitName.PASCAL },
                { "RADIAN", IfcSIUnitName.RADIAN },
                { "SECOND", IfcSIUnitName.SECOND },
                { "SIEMENS", IfcSIUnitName.SIEMENS },
                { "SIEVERT", IfcSIUnitName.SIEVERT },
                { "SQUARE_METRE", IfcSIUnitName.SQUARE_METRE },
                { "STERADIAN", IfcSIUnitName.STERADIAN },
                { "TESLA", IfcSIUnitName.TESLA },
                { "VOLT", IfcSIUnitName.VOLT },
                { "WATT", IfcSIUnitName.WATT },
                { "WEBER", IfcSIUnitName.WEBER }
            };
            //
            breakedownRootMap = new Dictionary <string, BreakdownItem>();          // prazdna mapa klasifikaci, bude plnena postupne
            //
            breakedownMap     = new Dictionary <int, BreakdownItem>();             // prazdna mapa trid, bude plnena postupne
            ifcPropertyMap    = new Dictionary <int, IfcSimplePropertyTemplate>(); // prazdna mapa vlastnosti, bude plnena postupne
            ifcPropertySetMap = new Dictionary <int, IfcPropertySetTemplate>();    // prazdna mapa skupin vlastnosti, bude plnena postupne
            reasonsMap        = new Dictionary <int, Reason>();                    // prazdna mapa IfcRelAssignsToControl, bude plnena postupne
            actorMap          = new Dictionary <string, Actor>();                  // prazdna mapa IfcRelAssignsToActor, bude plnena postupne
            milestonesCache   = new Dictionary <int, Milestone>();                 // prazdna mapa IfcRelAssignsToProcess, bude plnena postupne

            //using (var reader = new StreamReader("sfdi_export.csv"))
            using (var reader = new StreamReader(Console.OpenStandardInput()))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = new List <RecordLine>();
                    csv.Read(); // CSV header Line 0 - XbimEditorCredentials
                    csv.ReadHeader();

                    csv.Read(); // CSV line 0 - XbimEditorCredentials
                    var record = new RecordLine
                    {
                        Id       = csv.GetField <int>("Id"),
                        Pid      = csv.GetField <int>("Pid"),
                        Lvl      = csv.GetField <int>("Lvl") + 2, // -2..+inf -> 0..+inf
                        Method   = csv.GetField("Method"),
                        GlobalId = csv.GetField("GlobalId"),
                        Par01    = csv.GetField("Par01"),
                        Par02    = csv.GetField("Par02"),
                        Par03    = csv.GetField("Par03"),
                        Par04    = csv.GetField("Par04"),
                        Par05    = csv.GetField("Par05"),
                        Par06    = csv.GetField("Par06"),
                        Par07    = csv.GetField("Par07"),
                        Par08    = csv.GetField("Par08"),
                        Par09    = csv.GetField("Par09")
                    };
                    records.Add(record);

                    //START
                    var ifcFile    = args[0]; // tempfile // "/var/www/html/tmp/DDSS.ifc";
                    var doValidate = "validate";
                    if (args.Length > 1)
                    {
                        doValidate = args[1]; // "novalidate"
                    }
                    var editor = new XbimEditorCredentials
                    {
                        ApplicationFullName       = record.Par01, // "Databáze datového standardu stavebnictví"
                        ApplicationDevelopersName = record.Par02, // "Michal Kopecký"
                        ApplicationIdentifier     = record.Par03, // "DDSS"
                        ApplicationVersion        = record.Par04, // "1.0"
                        EditorsFamilyName         = record.Par05, // "Žák"
                        EditorsGivenName          = record.Par06, // "Josef"
                        EditorsOrganisationName   = record.Par07, // "Česká agentura pro standardizaci"
                    };

                    //IfcStore.ModelProviderFactory.UseMemoryModelProvider(); // OLD VERSION
                    // set up logger to file and console
                    var logFile = Path.ChangeExtension(ifcFile, ".log");
                    Log.Logger = new LoggerConfiguration()
                                 .Enrich.FromLogContext()
                                 .WriteTo.Console()
                                 .WriteTo.File(logFile)
                                 .CreateLogger();
                    XbimLogging.LoggerFactory.AddSerilog();

                    IfcStore.ModelProviderFactory.UseMemoryModelProvider();
                    using (var model = Model.Create(editor))
                    {
                        //var i = model.Internal.Instances;

                        //using (var txn = model.BeginTransaction()) // OLD VERSION
                        using (var txn = model.Internal.BeginTransaction("Model creation"))
                        {
                            // these will keep cache of units and enums
                            // units have to be defined in the source of 'UnitMap' (compile time) while
                            // enumerations are to be defined in runtime based on the values in the DB
                            var units = new UnitMap(model);
                            var enums = new EnumsMap(model);

                            while (csv.Read())
                            {
                                record = new RecordLine
                                {
                                    Id       = csv.GetField <int>("Id"),
                                    Pid      = csv.GetField <int>("Pid"),
                                    Method   = csv.GetField("Method"),
                                    GlobalId = csv.GetField("GlobalId"),
                                    Par01    = csv.GetField("Par01"),
                                    Par02    = csv.GetField("Par02"),
                                    Par03    = csv.GetField("Par03"),
                                    Par04    = csv.GetField("Par04"),
                                    Par05    = csv.GetField("Par05"),
                                    Par06    = csv.GetField("Par06"),
                                    Par07    = csv.GetField("Par07"),
                                    Par08    = csv.GetField("Par08"),
                                    Par09    = csv.GetField("Par09")
                                };
                                records.Add(record);
                                //Console.WriteLine(record.Method);

                                if (record.Method == "IfcClassification")
                                {
                                    var root = model.CreateBreakedownRoot(record.Par01, null); // "Klasifikace DSS, CCI:ET, CCI:CS, CCI:FS"

                                    // set name in default language
                                    root.SetName("en", record.Par01);

                                    // set name in other languages
                                    root.SetName("cs", "");

                                    breakedownRootMap.Add(record.Par01, root);
                                }
                                else if (record.Method == "IfcProjectLibrary")
                                {
                                    currentRequirementsSet = model.CreateRequirementSet(record.Par01, null); // "Level of Information Need"
                                    if (record.GlobalId != "")
                                    {
                                        currentRequirementsSet.Entity.GlobalId = record.GlobalId;
                                    }

                                    // set name in default language
                                    currentRequirementsSet.SetName("en", record.Par01);

                                    // set name in other languages
                                    currentRequirementsSet.SetName("cs", "");
                                }
                                else if (record.Method == "IfcRelAssignsToControl")
                                {
                                    // Purpose of the data requirement/exchange
                                    if (!reasonsMap.TryGetValue(record.Id, out Reason reason))
                                    {
                                        reason = model.CreateReason(record.Par01, record.Par02);
                                        if (record.GlobalId != "")
                                        {
                                            reason.Entity.GlobalId = record.GlobalId;
                                        }
                                        reasonsMap.Add(record.Id, reason);

                                        // set name in default language
                                        reason.SetName("en", record.Par01);

                                        // set name in other languages
                                        reason.SetName("cs", record.Par02);
                                    }
                                    reason.AddToContext(currentRequirementsSet);
                                }
                                else if (record.Method == "IfcRelAssignsToActor")
                                {
                                    // Actor / Role = Who is interested in the data
                                    if (!actorMap.TryGetValue(record.GlobalId, out Actor actor))
                                    {
                                        actor = model.CreateActor(record.Par01, null);
                                        if (record.GlobalId != "")
                                        {
                                            actor.Entity.GlobalId = record.GlobalId;
                                        }
                                        actorMap.Add(record.GlobalId, actor);

                                        // set name in default language
                                        actor.SetName("en", record.Par01);

                                        // set name in other languages
                                        actor.SetName("cs", "");
                                    }
                                    actor.AddToContext(currentRequirementsSet);
                                }
                                else if (record.Method == "IfcRelAssignsToProcess")
                                {
                                    // Milestone = point in time
                                    if (!milestonesCache.TryGetValue(record.Id, out Milestone milestone))
                                    {
                                        milestone = model.CreateMilestone(record.Par02, null);
                                        milestone.Entity.IsMilestone = record.Par03 == "true";

                                        if (record.GlobalId != "")
                                        {
                                            milestone.Entity.GlobalId = record.GlobalId;
                                        }
                                        milestonesCache.Add(record.Id, milestone);

                                        // set name in default language
                                        milestone.SetName("en", record.Par01);

                                        // set name in other languages
                                        milestone.SetName("cs", record.Par02);
                                    }
                                    milestone.AddToContext(currentRequirementsSet);
                                }
                                else if (record.Method == "IfcClassificationReference")
                                {
                                    // Class within classification
                                    // Set parent
                                    BreakdownItem parent = null;
                                    if (record.Par04 == "")
                                    {
                                        //Program.ifcCRS = Program.ifcCL; // classification for root class
                                        parent = breakedownRootMap[record.Par09]; // classification for root class
                                    }
                                    else
                                    {
                                        parent = breakedownMap[record.Pid]; // parent class othewise
                                    }
                                    // Optionally add new class
                                    if (!breakedownMap.ContainsKey(record.Id))
                                    {
                                        var item = model.CreateBreakedownItem(record.Par02, record.Par03, null, parent);
                                        breakedownMap.Add(record.Id, item);

                                        // set name in default language
                                        item.SetName("en", record.Par01);

                                        // set name in other languages
                                        item.SetName("cs", record.Par02);
                                    }
                                    ;
                                }
                                else if (record.Method == "IfcRelAssociatesClassification")
                                {
                                    breakedownMap[record.Id].AddToContext(currentRequirementsSet);
                                }
                                else if (record.Method == "IfcRelDeclares")
                                {
                                    // nothing to do, handled by LOIN library
                                }
                                else if (record.Method == "IfcPropertySetTemplate")
                                {
                                    if (ifcPropertySetMap.ContainsKey(record.Id))
                                    {
                                        PropertySetReused  = true;
                                        currentPropertySet = ifcPropertySetMap[record.Id];
                                    }
                                    else
                                    {
                                        PropertySetReused  = false;
                                        currentPropertySet = model.CreatePropertySetTemplate(record.Par01, null); // "Základní informace o místnostech"

                                        // set name in default language
                                        currentPropertySet.SetName("en", record.Par01);

                                        // set name in other languages
                                        currentPropertySet.SetName("cs", record.Par02);

                                        //ApplicableEntity
                                        //Description
                                        if (record.Par03 != "")
                                        {
                                            currentPropertySet.Description = record.Par03;

                                            // set name in default language
                                            currentPropertySet.SetDescription("en", record.Par03);

                                            // set name in other languages
                                            currentPropertySet.SetDescription("cs", record.Par04);
                                        }
                                        else if (record.Par04 != "")
                                        {
                                            currentPropertySet.Description = record.Par04;

                                            // set name in default language
                                            currentPropertySet.SetDescription("en", "");

                                            // set name in other languages
                                            currentPropertySet.SetDescription("cs", record.Par04);
                                        }
                                        if (record.GlobalId != "")
                                        {
                                            currentPropertySet.GlobalId = record.GlobalId;
                                        }
                                        ifcPropertySetMap.Add(record.Id, currentPropertySet);
                                    };
                                    currentRequirementsSet.Add(currentPropertySet);
                                }
                                else if (record.Method == "IfcSimplePropertyTemplate")
                                {
                                    if (!PropertySetReused)
                                    {
                                        if (!ifcPropertyMap.TryGetValue(record.Id, out IfcSimplePropertyTemplate propertyTemplate))
                                        {
                                            propertyTemplate = model.New <IfcSimplePropertyTemplate>(p =>
                                            {
                                                p.Name = record.Par08; // "Název EN"

                                                // Set description in primary language
                                                p.SetName("en", record.Par08);

                                                // Set description in other languages
                                                p.SetName("cs", record.Par01);
                                            });
                                            if (record.GlobalId != "")
                                            {
                                                propertyTemplate.GlobalId = record.GlobalId;
                                            }
                                            //Description
                                            if (record.Par09 != "")
                                            {
                                                propertyTemplate.Description = record.Par09;

                                                // Set description in primary language
                                                propertyTemplate.SetDescription("en", record.Par09);

                                                // Set description in other languages
                                                propertyTemplate.SetDescription("cs", record.Par02);
                                            }
                                            else if (record.Par02 != "")
                                            {
                                                propertyTemplate.Description = record.Par02;

                                                // Set description in primary language
                                                propertyTemplate.SetDescription("en", "");

                                                // Set description in other languages
                                                propertyTemplate.SetDescription("cs", record.Par02);
                                            }

                                            if (record.Par03 != "") // dataunit
                                            {
                                                propertyTemplate.PrimaryUnit = units[record.Par03];
                                            }
                                            if (record.Par04 != "") // nameof(X) -> "X"
                                            {
                                                propertyTemplate.PrimaryMeasureType = record.Par04;
                                            }
                                            //TemplateType
                                            switch (record.Par05)
                                            {
                                            case "P_SINGLEVALUE":
                                                propertyTemplate.TemplateType = IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE;
                                                break;

                                            case "P_ENUMERATEDVALUE":
                                                propertyTemplate.TemplateType = IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE;
                                                propertyTemplate.Enumerators  = enums.GetOrAdd(record.Par06, record.Par07.Split(",", StringSplitOptions.RemoveEmptyEntries)); // { "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"}
                                                break;

                                            case "P_REFERENCEVALUE":
                                                propertyTemplate.TemplateType = IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE;
                                                break;

                                            case "P_BOUNDEDVALUE":
                                                propertyTemplate.TemplateType = IfcSimplePropertyTemplateTypeEnum.P_BOUNDEDVALUE;
                                                break;

                                            default:
                                                Console.WriteLine("IfcSimplePropertyTemplate: UNKNOWN TEMPLATE TYPE ", record.Par05);
                                                //Program.ifcSPT.TemplateType = ...
                                                break;
                                            }
                                            ;
                                            ifcPropertyMap.Add(record.Id, propertyTemplate);
                                        }
                                        ;

                                        currentPropertySet.HasPropertyTemplates.Add(propertyTemplate);
                                        currentPropertyTemplate = propertyTemplate;
                                    }
                                    ;
                                }
                                else if (record.Method == "IfcSIUnit")
                                {
                                    var unit = model.New <IfcSIUnit>();
                                    //Name
                                    //Program.ifcISU.Name = IfcSIUnitName.SQUARE_METRE;
                                    try
                                    {
                                        unit.Name = ifcSIUnitMap[record.Par01];
                                    }
                                    catch (KeyNotFoundException)
                                    {
                                        Console.WriteLine("IfcSIUnit: UNKNOWN NAME ", record.Par01);
                                        //ifcISU.Name = IfcSIUnitName. ...
                                    }
                                    //UnitType
                                    switch (record.Par02)
                                    {
                                    case "AREAUNIT":
                                        unit.UnitType = IfcUnitEnum.AREAUNIT;
                                        break;

                                    default:
                                        Console.WriteLine("IfcSIUnit: UNKNOWN UNIT TYPE ", record.Par02);
                                        //ifcISU.UnitType = ...
                                        break;
                                    }
                                    ;
                                    currentPropertyTemplate.PrimaryUnit = unit;
                                }
                                else if (record.Method == "IfcDocumentReference")
                                {
                                    // Declared data requirements / templates
                                    model.New <IfcRelAssociatesDocument>(rd => {
                                        rd.RelatedObjects.Add(currentPropertyTemplate);
                                        rd.RelatingDocument = model.New <IfcDocumentReference>(doc => {
                                            doc.Identification = record.Par01; // "Vyhláška č. 441/2013 Sb."
                                            doc.Location       = record.Par02; // "https://www.mfcr.cz/cs/legislativa/legislativni-dokumenty/2013/vyhlaska-c-441-2013-sb-16290"
                                            doc.Name           = record.Par03; // "Vyhláška k provedení zákona o oceňování majetku (oceňovací vyhláška)"
                                        });
                                    });
                                }
                                ;
                            }
                            ; // konec while read
                            txn.Commit();
                        }

                        // validate schema and proper units
                        var validator = new IfcValidator();
                        var valid     = validator.Check(model.Internal);
                        if (doValidate != "novalidate" && !valid)
                        {
                            throw new Exception("Invalid model shouldn't be stored and used for any purposes.");
                        }

                        // this is stdout if you want to use it
                        //var stdout = Console.OpenStandardOutput();

                        // writing to stream (any stream)
                        using (var stream = File.Create(ifcFile))
                        {
                            if (Path.GetExtension(ifcFile) == ".ifcxml")
                            {
                                model.Internal.SaveAsIfcXml(stream);
                            }
                            else
                            {
                                model.Internal.SaveAsIfc(stream);
                            };
                        }

                        //model.SaveAs("DDSS.ifc");
                        //model.SaveAs("DDSS.ifcxml");
                        //model.SaveAs(ifcFile); // args[0]
                    }
                    //STOP
                }// csv
        }