AE+C#实现:在SceneControl里打开和保存

来自:http://www.cnblogs.com/zhuxy/archive/2012/03/30/2424672.html

之前编写这段代码,发现一直没有C#编写的,现在贴出来,希望对大家有用

此程序实现保存后的文件,不能在ArcScene里面打开。但下面的打开程序一切通吃。。呵呵

打开代码:

openFileDialog1.Title = "打开Scene文档";
            openFileDialog1.Filter = "Scene文档(*.sxd)|*.sxd";
            openFileDialog1.ShowDialog();
            string filename = openFileDialog1.FileName;
            if (axSceneControl1.CheckSxFile(filename))
                axSceneControl1.LoadSxFile(filename);
            else
            {
                IScene pScene = axSceneControl1.Scene;
                IMemoryBlobStream mbStream = new MemoryBlobStreamClass();
                IObjectStream objectStream = new ObjectStreamClass();
                mbStream.LoadFromFile(filename);
                IPersistStream pPersistStream = (ESRI.ArcGIS.esriSystem.IPersistStream)pScene;
                objectStream.Stream = mbStream;
                pPersistStream.Load(objectStream);               
            }

保存代码

IMemoryBlobStream mbStream = new MemoryBlobStreamClass();
                        IObjectStream objectStream = new ObjectStreamClass();
                        objectStream.Stream = mbStream;
                        IPersistStream persistStream = (ESRI.ArcGIS.esriSystem.IPersistStream)axSceneControl1.Scene;
                        persistStream.Save(objectStream, 1);

                        saveFileDialog1.Title = "保存Scene文档";
                        saveFileDialog1.Filter = "保存Scene文档(*.sxd)|*.sxd";
                        saveFileDialog1.ShowDialog();
                        string filename = saveFileDialog1.FileName;

                        mbStream.SaveToFile(filename);
                        MessageBox.Show("OK");

你可能感兴趣的:(C#)