Example #1
0
        public void CanConvertOneFile()
        {
            var ifc  = new FileInfo("OneWallTwoWindows.ifc");
            var xbim = CreateGeometry(ifc, true, false);

            using (var s = IfcStore.Open(xbim.FullName))
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                var savename = Path.ChangeExtension(s.FileName, ".gltf");
                var bldr     = new Builder();
                var ret      = bldr.BuildInstancedScene(s, XbimMatrix3D.Identity);
                glTFLoader.Interface.SaveModel(ret, savename);

                Debug.WriteLine($"Gltf Model exported to '{savename}' in {sw.ElapsedMilliseconds} ms.");
                FileInfo f = new FileInfo(s.FileName);

                // write json
                //
                var jsonFileName = Path.ChangeExtension(s.FileName, "json");
                var bme          = new Xbim.GLTF.SemanticExport.BuildingModelExtractor();
                var rep          = bme.GetModel(s);
                rep.Export(jsonFileName);
            }
        }
Example #2
0
        private void ExportSingle_Click(object sender, RoutedEventArgs e)
        {
            IfcStore s = Model as IfcStore;

            if (s == null || string.IsNullOrEmpty(s.FileName))
            {
                MessageBox.Show("Please save the model in xbim format before exporting.");
                return;
            }


            // ILog Log = LogManager.GetLogger("Xbim.Gltf.XplorerGltfExporter");

            var curr = this.Cursor;

            Cursor = System.Windows.Input.Cursors.Wait;
            try
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                var savename = Path.ChangeExtension(s.FileName, ".gltf");
                var bldr     = new Builder();
                var ret      = bldr.BuildInstancedScene(Model, XbimMatrix3D.Identity);
                glTFLoader.Interface.SaveModel(ret, savename);

                // Log.Info($"Gltf Model exported to '{savename}' in {sw.ElapsedMilliseconds} ms.");
                FileInfo f = new FileInfo(s.FileName);

                // write json
                //
                var jsonFileName = Path.ChangeExtension(s.FileName, "json");
                var bme          = new Xbim.GLTF.SemanticExport.BuildingModelExtractor();
                var rep          = bme.GetModel(s);
                rep.Export(jsonFileName);

                // decide if showing the model.
                //
                var answ = MessageBox.Show("File created, do you want to show it in windows explorer?", "Completed", MessageBoxButton.YesNo);
                if (answ == MessageBoxResult.Yes)
                {
                    SelectFile(savename);
                }

                //System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
                //{
                //    FileName = f.DirectoryName,
                //    UseShellExecute = true,
                //    Verb = "open"
                //});
            }
            catch (System.Exception err)
            {
                // Log.Error("Error exporting gltf, see inner exception for details.", err);
            }
            Cursor = curr;
        }