ARCEngine 开发,CAD数据操作

                    

          题记:数据转换过程中总是存在着数据丢失和转换不完美的地方,特别是异构数据。

打开CAD数据

        打开CAD数据的方法比较多,下面简单列举一些来源于其他博客的方法:

    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//如果是点、线、面,则添加要素层
  {
  pFeatureLayer = new FeatureLayerClass();<span style="font-family: Arial, Helvetica, sans-serif;">     }</span><pre code_snippet_id="1902356" snippet_file_name="blog_20160927_3_4611722" name="code" class="csharp">pFeatureLayer.Name = pFeatureClass.AliasName;
  pFeatureLayer.FeatureClass = pFeatureClass;
  this.axmc_Main.Map.AddLayer(pFeatureLayer);
  

属性处理

使用ARCGIS 打开CAD的属性都包含以下信息

通过CADWorkspaceFactory打开的属性包含以下属性值

Ann:(55个字段)

OBJECTID        Entity        Handle       
Owner        Layer       
LyrFrzn        LyrLock        LyrOn       
LyrVPFrzn       
LyrHandle
        Color        EntColor        LyrColor        BlkColor        Linetype        EntLinetyp        LyrLnType        BlkLinetyp        Elevation        Thickness        LineWt       
EntLineWt        LyrLineWt        BlkLineWt        RefName        LTScale        ExtX        ExtY        ExtZ        DocName        DocPath        DocType        DocVer        ScaleX        ScaleY        ScaleZ       
Style        FontID       
Text        Height        TxtAngle        TxtWidth        TxtOblique        TxtGenType        TxtJust        VertAlign        TxtFont        TxtBoxHt        TxtBoxWd        TxtRefWd        TxtAttach       
TxtDir        LnSpace        SpaceFct        TxtMemo        

Point:(36个字段)

OBJECTID        EntityHandle        LayerLyrFrzn        LyrLockLyrOn        LyrVPFrznLyrHandle        ColorEntColor        LyrColorBlkColor        LinetypeEntLinetyp        LyrLnTypeBlkLinetyp        ElevationThickness        LineWtEntLineWt        LyrLineWtBlkLineWt
       RefNameLTScale        AngleExtX        ExtYExtZ        DocNameDocPath        DocTypeDocVer        ScaleXScaleY        ScaleZ

Line(33个字段)

OBJECTID        EntityHandle        LayerLyrFrzn        LyrLockLyrOn        LyrVPFrznLyrHandle        ColorEntColor        LyrColorBlkColor        LinetypeEntLinetyp        LyrLnTypeBlkLinetyp        ElevationThickness        LineWtEntLineWt        LyrLineWtBlkLineWt
       RefNameLTScale        ExtXExtY        ExtZDocName        DocPathDocType        DocVerShape_STLe

Polygon(34个字段)

OBJECTID        EntityHandle        LayerLyrFrzn        LyrLockLyrOn        LyrVPFrznLyrHandle        ColorEntColor        LyrColorBlkColor        LinetypeEntLinetyp        LyrLnTypeBlkLinetyp        ElevationThickness        LineWtEntLineWt        LyrLineWtBlkLineWt
       RefNameLTScale        ExtXExtY        ExtZDocName        DocPathDocType        DocVerShape_STAr        Shape_STLe

转载自:https://blog.csdn.net/wujianyouhun/article/details/52677726

You may also like...