Browse Source

mxg:添加Layer是否关闭导出

mengxiangge 5 years ago
parent
commit
26dcc8f933
5 changed files with 71 additions and 7 deletions
  1. 22 5
      AutoCADConnector.cs
  2. 1 0
      CadExport.csproj
  3. 6 0
      CadExport.csproj.user
  4. 21 0
      Model/Layer.cs
  5. 21 2
      README.md

+ 22 - 5
AutoCADConnector.cs

@@ -174,7 +174,7 @@ namespace SmartSoft.ACAD
             try
             {
                 var mbiDoc = TestCad.Model.Document.CreateDocument();
-
+                #region BlockTable
                 foreach (dbx.AcadEntity entity in thisDrawing.ModelSpace)
                 {
                     if (entity is dbx.AcadBlockReference blockReference)
@@ -242,11 +242,11 @@ namespace SmartSoft.ACAD
                         }
                         else if (entity is dbx.AcadSolid solid)
                         {
-                          
+
                         }
                         else if (entity is dbx.AcadPoint point)
                         {
-                        
+
                         }
                         else if (entity is dbx.AcadArc arc)
                         {
@@ -262,7 +262,7 @@ namespace SmartSoft.ACAD
                         }
                         else if (entity is dbx.AcadAttribute attribute)
                         {
-                           
+
                         }
                         else
                         {
@@ -278,6 +278,23 @@ namespace SmartSoft.ACAD
                     }
 
                 }// end of foreach thisDrawing.ModelSpace
+                #endregion
+
+                #region LayerTable
+
+                foreach (var entity in thisDrawing.Layers)
+                {
+                    if (entity is dbx.AcadLayer layer)
+                    {
+                        var cadObject = new TestCad.Model.Layer();
+                        cadObject.Handle = layer.Handle;
+                        cadObject.Layer = layer.Name;
+                        cadObject.IsOff = layer.LayerOn;
+                        mbiDoc.AddObject(cadObject);
+                    }
+                }
+
+                #endregion
                 mbiDoc.GroupElements();
                 string dataStr = JsonConvert.SerializeObject(mbiDoc);
                 string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
@@ -292,7 +309,7 @@ namespace SmartSoft.ACAD
                 System.Windows.Forms.MessageBox.Show("图形中有未知的错误,格式不正确或图形数据库需要修愎。系统错误提示:" + e.Message, "信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                 thisDrawing = null;
             }//end of catch
-            
+
         }//end of function GetBlockReference
 
         #endregion

+ 1 - 0
CadExport.csproj

@@ -79,6 +79,7 @@
     <Compile Include="Model\Document.cs" />
     <Compile Include="Model\DBText.cs" />
     <Compile Include="Model\Circle.cs" />
+    <Compile Include="Model\Layer.cs" />
     <Compile Include="Model\Line.cs" />
     <Compile Include="Model\PolyLine.cs" />
     <Compile Include="Model\XYZ.cs" />

+ 6 - 0
CadExport.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>

+ 21 - 0
Model/Layer.cs

@@ -0,0 +1,21 @@
+/* ==============================================================================
+ * 功能描述:Layer  
+ * 创 建 者:Garrett
+ * 创建日期:2019/12/24 11:37:47
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TestCad.Model
+{
+    /// <summary>
+    /// Layer
+    /// </summary>
+    class Layer:CADObject
+    {
+        public bool IsOff { get; set; }
+    }
+}

+ 21 - 2
README.md

@@ -1,9 +1,10 @@
 # CAD 已导出类型:  
 AcadBlockReference、AcadLine、AcadLWPolyline、AcadText、AcadMText、AcadCircle、AcadArc
+AcadLayer
 # 暂时未导出类型:  
 AcadHatch、AcadSolid、AcadPoint、AcadAttribute、AcDbAlignedDimension
 
-### 
+# Block
 ## AcadBlockReference 块
 
 ```json
@@ -187,4 +188,22 @@ AcadHatch、AcadSolid、AcadPoint、AcadAttribute、AcDbAlignedDimension
 | Radius   | 半径   |  50.0  | 
 | StartPoint   | 开始点   |    | 
 | EndPoint   | 结束点   |    | 
-| Normal   | 法向量   |    | 
+| Normal   | 法向量   |    | 
+
+# Layer
+
+## AcadLayer Layer
+
+```json
+{
+"IsOff": true,
+"Handle": "357",
+"Layer": "室内布置"
+}     
+```  
+
+| 名称   | 解释   | 示例    
+|:---:|:---:|:---:|
+| Handle   | CAD的Handle   | 357   | 
+| Layer   | 所属的图层   | 室内布置   | 
+| IsOff   |  开关图层  |  true  |