ArcEngine 開啟AutoCAD檔案的幾種方法與讀取CAD資料的方法

shileimohan發表於2020-10-21

方法一、

IWorkspaceFactory pWorkspaceFactory;
IFeatureWorkspace pFeatureWorkspace;
IFeatureLayer pFeatureLayer;
IFeatureDataset pFeatureDataset;
//開啟CAD資料集
pWorkspaceFactory = new CadWorkspaceFactoryClass();
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(directoryPath, 0);
//開啟一個要素集
pFeatureDataset = pFeatureWorkspace.OpenFeatureDataset(fileName);
//IFeaturClassContainer可以管理IFeatureDataset中的每個要素類
IFeatureClassContainer pFeatureClassContainer = (IFeatureClassContainer)pFeatureDataset;
//對CAD檔案中的要素進行遍歷處理
for (int i = 0; i < pFeatureClassContainer.ClassCount - 1; i++)
{
IFeatureClass pFeatureClass = pFeatureClassContainer.get_Class(i);
if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
{
//如果是註記,則新增註記層
pFeatureLayer = new CadAnnotationLayerClass();
}
else//

相關文章