在论坛中有很多人提到ae9.2中不能加载显示cad,本人细心研究了一下,ae9.1和ae9.2加载cad的方式有点不同,现把代码贡献出来,共大家参考(本人已测试过,可用)
private void OpenCadFile()
{
//设置workspace
IWorkspaceFactory pWorkspaceFact=new CadWorkspaceFactoryClass();
//Open the Workspace
IWorkspace pWorkspace;
pWorkspace = pWorkspaceFact.OpenFromFile(@"E:\", 0);
//设置CadDrawingWorkspace
ICadDrawingWorkspace pCadDwgWorkspace = (ICadDrawingWorkspace)pWorkspace;
//Open the CadDrawingDataset
ICadDrawingDataset pCadDwgDataset;
pCadDwgDataset = pCadDwgWorkspace.OpenCadDrawingDataset("15413422.DWG");
//在Mapcontrol中打开CAD图形
if (pCadDwgDataset == null) return;
ICadLayer pCadLayer = new CadLayerClass();
pCadLayer.CadDrawingDataset = pCadDwgDataset;
this.axMapControl1.AddLayer(pCadLayer, 0);
}