ArcEngine提供了加载3dd文件的方法,却没有开放保存3dd文件的接口,通过查找资料,主要是采用二进制段实现了3dd文件的保存和加载,但是用这种方法保存的3dd文件其实是“伪”3dd文件,在ArcGlobe下是打不开的。下面是源代码:
private void button_Open3dd_Click (object sender,EventArgs e)
{
try
{
ClearGlobe();
OpenFileDialog open3ddDialog = new OpenFileDialog();
open3ddDialog.Title = "打开3dd文件";
open3ddDialog.Filter = "3dd文件(*.3dd)|*.3dd";
if(open3ddDialog.ShowDialog() == DialogResult.OK)
{
if(axGlobeControl1.Check3dFile(open3ddDialog.FileName))
{
axGlobeControl1.Load3dFile(open3ddDialog.FileName);
}
else
{
IObjectStream pObjectStream = new ObjectStreamClass();
IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();
pMemoryBlobStream.LoadFromFile(open3ddDialog.FileName);
IPersistStream pPersistStream = m_globeControl.Globe as IPersistStream;
pObjectStream.Stream = pMemoryBlobStream;
pPersistStream.Load(pObjectStream);
}
}
else
{
return;
}
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_Save3dd_Click (object sender,EventArgs e)
{
try
{
SaveFileDialog save3ddDialog = new SaveFileDialog();
save3ddDialog.Title = "保存3dd文件";
save3ddDialog.Filter = "3dd文件(*.3dd)|*.3dd";
save3ddDialog.FileName = "test.3dd";
if (save3ddDialog.ShowDialog()==DialogResult.OK)
{
IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStream();
IObjectStream pObjectStream = new ObjectStream();
pObjectStream.Stream = pMemoryBlobStream;
IPersistStream pPersistStream = m_globeControl.Globe as IPersistStream;
pPersistStream.Save(pObjectStream,1);
pMemoryBlobStream.SaveToFile(save3ddDialog.FileName);
}
else
{
return;
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
还有需要注意的问题:如果在加载3dd时,当前globecontrol中有图层存在的话,会出现闪退,我在这里只是简单的把当前globe中的所有图层清空(ClearGlobe函数),也可以采用ArcGlobe的方式写一个提示对话框的方式来处理,这样就不会出现闪退了
今天的文章arcgis导入3d模型_3d object文件怎么打开「建议收藏」分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/85369.html