public void ConvertDPoWToCOBieLite()
        {
            var          pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow");
            const string dir = "Export";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var outputs = new List <string>();

            foreach (var stage in pow.ProjectStages)
            {
                var facility  = new FacilityType();
                var exchanger = new DPoWToCOBieLiteExchanger(pow, facility, stage);
                exchanger.Convert();
                var output = Path.Combine(dir, stage.Name + ".json");
                outputs.Add(output);
                facility.WriteJson(output);
            }

            //check all result files exist
            foreach (var output in outputs)
            {
                Assert.IsTrue(File.Exists(output));
            }

            //try to reload to make sure serialization and deserilization works in both directions
            foreach (var output in outputs)
            {
                var facility = FacilityType.ReadJson(output);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Perform the conversion, writing data to the provided output path
        /// </summary>
        /// <param name="outputFilePath">Path of output xml file (should have the extension .xml so the MPXJ library automatically infers the file type)</param>
        public void Convert(string outputFilePath)
        {
            // Open and parse dPOW file
            pow = PlanOfWork.OpenJson(inputFilePath);

            // Create project file
            project = new ProjectFile();

            // Insert data to project file
            InsertDataToProject();

            // Write file to mpx
            ProjectWriter mpxWriter = ProjectWriterUtility.getProjectWriter(outputFilePath);

            mpxWriter.write(project, outputFilePath);
        }
        public void CheckDocumentsInDPoW()
        {
            var pow = PlanOfWork.OpenJson("013-Lakeside_Restaurant.dpow");
            var num = 0;

            foreach (var stage in pow.ProjectStages ?? new List <ProjectStage>())
            {
                foreach (var documentation in stage.DocumentationSet ?? new List <Documentation>())
                {
                    if (documentation.Attributes != null)
                    {
                        num += documentation.Attributes.Count;
                    }
                }
            }
            //Assert.AreEqual(0, num);
        }
Beispiel #4
0
        public void Dpow2CobieLite2Ifc()
        {
            var          pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow");
            const string dir = "..\\..\\Export";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            foreach (var stage in pow.ProjectStages)
            {
                var facility = new FacilityType();
                var d2C      = new DPoWToCOBieLiteExchanger(pow, facility, stage);
                d2C.Convert();

                var outputIfc       = Path.Combine(dir, stage.Name + ".DPoW.ifc");
                var outputCobieJson = Path.Combine(dir, stage.Name + ".DPoW.json");
                var outputCobieXml  = Path.Combine(dir, stage.Name + ".DPoW.xml");
                facility.WriteJson(outputCobieJson);
                facility.WriteXml(outputCobieXml);
                var credentials = new XbimEditorCredentials()
                {
                    ApplicationDevelopersName = "XbimTeam",
                    ApplicationFullName       = "Xbim.Exchanger",
                    EditorsOrganisationName   = "Xbim Development Team",
                    EditorsFamilyName         = "Xbim Tester",
                    ApplicationVersion        = "3.0"
                };
                using (var model = IfcStore.Create(credentials, IfcSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel))
                {
                    using (var txn = model.BeginTransaction("Convert from COBieLite"))
                    {
                        var c2Ifc = new CoBieLiteToIfcExchanger(facility, model);
                        c2Ifc.Convert();
                        txn.Commit();
                    }
                    model.SaveAs(outputIfc, IfcStorageType.Ifc);

                    if (facility.AssetTypes != null)
                    {
                        Assert.AreEqual(facility.AssetTypes.Count(), model.Instances.OfType <IfcTypeObject>().Count());
                    }
                }
            }
        }
        public void ConvertDPoWToAll()
        {
            var          pow = PlanOfWork.OpenJson("001-Lakeside_Restaurant.dpow");
            const string dir = "..\\..\\COBieLiteUK";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string msg;

            foreach (var stage in pow.ProjectStages)
            {
                var json = Path.Combine(dir, stage.Name + ".cobie.json");
                var xlsx = Path.Combine(dir, stage.Name + ".xlsx");
                var ifc  = Path.Combine(dir, stage.Name + ".ifc");

                var facility       = new Xbim.CobieLiteUk.Facility();
                var cobieExchanger = new DPoWToCOBieLiteUKExchanger(pow, facility, stage);
                cobieExchanger.Convert(DateTime.Now);

                facility.WriteJson(json, true);
                facility.WriteCobie(xlsx, out msg);


                //using (var ifcModel = XbimModel.CreateTemporaryModel())
                //{
                //    ifcModel.Initialise("Xbim Tester", "XbimTeam", "Xbim.Exchanger", "Xbim Development Team", "3.0");
                //    using (var txn = ifcModel.BeginTransaction("Conversion from COBie"))
                //    {
                //        ifcModel.Header.FileName.Name = stage.Name;
                //        ifcModel.ReloadModelFactors();
                //        var ifcExchanger = new XbimExchanger.COBieLiteUkToIfc.CoBieLiteUkToIfcExchanger(facility, ifcModel);
                //        ifcExchanger.Convert();
                //        txn.Commit();
                //    }
                //    ifcModel.SaveAs(ifc, XbimStorageType.IFC);
                //    ifcModel.Close();
                //}
            }
        }
        public void Dpow2CobieLite2Ifc()
        {
            var          pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow");
            const string dir = "..\\..\\Export";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            foreach (var stage in pow.ProjectStages)
            {
                var facility = new FacilityType();
                var d2C      = new DPoWToCOBieLiteExchanger(pow, facility, stage);
                d2C.Convert();

                var outputIfc       = Path.Combine(dir, stage.Name + ".DPoW.ifc");
                var outputCobieJson = Path.Combine(dir, stage.Name + ".DPoW.json");
                var outputCobieXml  = Path.Combine(dir, stage.Name + ".DPoW.xml");
                facility.WriteJson(outputCobieJson);
                facility.WriteXml(outputCobieXml);

                using (var model = XbimModel.CreateTemporaryModel())
                {
                    model.Initialise("Xbim Tester", "XbimTeam", "Xbim.Exchanger", "Xbim Development Team", "3.0");
                    model.ReloadModelFactors();
                    using (var txn = model.BeginTransaction("Convert from COBieLite"))
                    {
                        var c2Ifc = new CoBieLiteToIfcExchanger(facility, model);
                        c2Ifc.Convert();
                        txn.Commit();
                    }
                    model.SaveAs(outputIfc, XbimStorageType.IFC);

                    if (facility.AssetTypes != null)
                    {
                        Assert.AreEqual(facility.AssetTypes.Count(), model.Instances.OfType <IfcTypeObject>().Count());
                    }
                }
            }
        }
        public void ConvertDPoWToCOBieLite()
        {
            //var pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow");
            var          pow = PlanOfWork.OpenJson("013-Lakeside_Restaurant.dpow");
            const string dir = "..\\..\\COBieLiteUK";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var    outputs = new List <string>();
            string msg;

            foreach (var stage in pow.ProjectStages)
            {
                var facility  = new Xbim.CobieLiteUk.Facility();
                var exchanger = new DPoWToCOBieLiteUKExchanger(pow, facility, stage);
                exchanger.Convert();
                var output = Path.Combine(dir, stage.Name + ".cobieliteUK.json");
                var xls    = Path.Combine(dir, stage.Name + ".xlsx");
                outputs.Add(output);
                facility.WriteJson(output, true);
                facility.WriteCobie(xls, out msg);
            }

            //check all result files exist
            foreach (var output in outputs)
            {
                Assert.IsTrue(File.Exists(output));
            }

            //try to reload to make sure serialization and deserilization works in both directions
            foreach (var output in outputs)
            {
                var facility = Xbim.CobieLiteUk.Facility.ReadJson(output);
            }
        }