Browse Source

xls:空间解析类

xulisong 5 years ago
parent
commit
611ffc412c

BIN
JBIM/Dlls/SAGA.DotNetUtils.dll


BIN
JBIM/Dlls/SAGA.RevitAPI.dll


BIN
JBIM/Dlls/SAGA.RevitUtility.dll


BIN
JBIM/Dlls/SAGA.RevitUtils.dll


+ 4 - 0
JBIM/JBIM/Component/BoundarySegment.cs

@@ -22,6 +22,10 @@ namespace JBIM.Component
             Curve = new List<XYZ>();
         }
         /// <summary>
+        /// 参照元素
+        /// </summary>
+        public BimId Reference { get; set; }
+        /// <summary>
         /// 关联线
         /// </summary>
         public List<XYZ> Curve { get; private set; }

+ 2 - 2
JBIM/JBIM/Component/Space.cs

@@ -19,8 +19,8 @@ namespace JBIM.Component
     {
         public Space()
         {
-            BoundarySegments = new List<BimId>();
+            BoundarySegments = new List<List<BimId>>();
         }
-        public List<BimId> BoundarySegments { get; private set; }
+        public List<List<BimId>> BoundarySegments { get; private set; }
     }
 }

+ 2 - 0
JBIM/JBIM/Definition/TypeDefinition.cs

@@ -53,6 +53,8 @@ namespace JBIM
         Property_ConnectedIds = Relationship - 4,
         [Description("Host")]
         Property_Host = Relationship - 5,
+        [Description("Reference")]
+        Property_Reference = Relationship - 6,
         #endregion
     }
 }

BIN
JBIM/JBIM/bin/Debug/JBIM.dll


BIN
JBIM/JBIM/bin/Debug/JBIM.pdb


BIN
JBIM/RevitExport/bin/Debug/SAGA.DotNetUtils.dll


BIN
JBIM/RevitExport/bin/Debug/SAGA.RevitAPI.dll


BIN
JBIM/RevitExport/bin/Debug/SAGA.RevitUtility.dll


BIN
JBIM/RevitExport/bin/Debug/SAGA.RevitUtils.dll


+ 63 - 1
JBIM/RevitToJBim/ComponentParse/ParseSpace.cs

@@ -13,9 +13,15 @@ using System.Threading.Tasks;
 using Autodesk.Revit.DB.Mechanical;
 using JBIM;
 using RevitExport;
+using RevitToJBim.Common;
+using SAGA.RevitUtils.Extends;
+using JSpace = JBIM.Component.Space;
+using JBoundarySegment = JBIM.Component.BoundarySegment;
+using Autodesk.Revit.DB;
 
 namespace RevitToJBim.ComponentParse
 {
+    [UsableParse]
     public class ParseSpace : ParseBase
     {
         public override List<string> FastIndex()
@@ -28,7 +34,63 @@ namespace RevitToJBim.ComponentParse
         }
         protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
         {
-            throw new NotImplementedException();
+            if (!(wrapper.RefElement is Space space))
+            {
+                return null;
+            }
+            //if (!space.IsSpace())
+            //{
+            //    return null;
+            //}
+            JSpace bimObject = new JSpace();
+            ParseCore.AttachObject(bimObject, wrapper);
+            bimObject.Location.Add(BimConvert.ConvertToXYZ(space.Location.GetPoint()));
+
+            var segments = space.GetBoundarySegments(new SpatialElementBoundaryOptions());
+            if (segments != null)
+            {
+                foreach (IList<BoundarySegment> segmentList in segments)
+                {
+                    Polygon outLine = new Polygon();
+                    List<BimId> segmentBimids = new List<BimId>();
+                    foreach (BoundarySegment segment in segmentList)
+                    {
+                        var points = segment.GetCurve().GetPoints();
+                        var usePoints = points.Select(xyz => BimConvert.ConvertToXYZ(xyz)).ToList();
+                        outLine.AddRange(usePoints.GetRange(0, usePoints.Count - 1));
+
+                        #region 解析线段类
+
+                        JBoundarySegment jSegment = new JBoundarySegment();
+                        jSegment.Curve.AddRange(usePoints);
+                        var jSegmentId=context.AddBimObject(jSegment);
+                        segmentBimids.Add(jSegmentId);
+                        var referenceElementId = segment.ElementId;
+                        if (referenceElementId != null)
+                        {
+                            ElementOneToOneRel rel = new ElementOneToOneRel(jSegmentId.ToString(), referenceElementId.ToString());
+                            rel.SetElementType(TypeDefinition.Property_Reference);
+                            rel.RelatingObjectIsBimId = true;
+                            context.RelationShips.Add(rel);
+                        }                 
+                        #endregion
+
+                    }
+
+                    if (outLine.Any())
+                    {
+                        bimObject.OutLine.Add(outLine);
+                    }
+
+                    if (segmentBimids.Any())
+                    {
+                        bimObject.BoundarySegments.Add(segmentBimids);
+                    }
+                }
+            }
+ 
+            context.AddBimObject(bimObject);
+            return new List<BimId>();
         }
     }
 }

+ 20 - 3
JBIM/RevitToJBim/JBimParseContext.cs

@@ -108,11 +108,28 @@ namespace RevitToJBim
 
             return BimJsonUtil.Serializer(Document);
         }
+        /// <summary>
+        /// 获取关联对象的BimId
+        /// </summary>
+        /// <param name="ship"></param>
+        /// <returns></returns>
+        private BimId GetRelatingBimId(ElementRelationShip ship)
+        {
+            BimId relatingid = null;
+            if (ship.RelatingObjectIsBimId)
+            {
+                relatingid = new BimId(ship.RelatingObject);
+            }
+            else
+            {
+                relatingid = GetBimId(ship.RelatingObject);
+            }
 
-    
+            return relatingid;
+        }
         private RelationshipBase ConvertRelationShipInfo(ElementRelationShip ship)
         {
-            var relatingid = GetBimId(ship.RelatingObject);
+            BimId relatingid = GetRelatingBimId(ship);    
             RelationshipBase useShip = null;
             if (relatingid == null)
             {
@@ -140,7 +157,7 @@ namespace RevitToJBim
 
         private void UpdateRelationShipInfo(ElementRelationShip ship)
         {
-            var relatingid = GetBimId(ship.RelatingObject);
+            var relatingid = GetRelatingBimId(ship);
             if (relatingid == null)
             {
                 return;

+ 2 - 0
JBIM/RevitToJBim/ParseData/ElementRelationShip.cs

@@ -19,7 +19,9 @@ namespace RevitToJBim
         public ElementRelationShip()
         {
             IsProperty = true;
+            RelatingObjectIsBimId = false;
         }
+        public bool RelatingObjectIsBimId { get; set; }
         /// <summary>
         /// 主体对象
         /// </summary>

+ 5 - 2
JBIM/RevitToJBim/RevitToJBim.csproj

@@ -40,8 +40,11 @@
     <Reference Include="RevitAPIUI">
       <HintPath>..\Dlls\RevitAPIUI.dll</HintPath>
     </Reference>
-    <Reference Include="SAGA.RevitUtility">
-      <HintPath>..\Dlls\SAGA.RevitUtility.dll</HintPath>
+    <Reference Include="SAGA.DotNetUtils">
+      <HintPath>..\Dlls\SAGA.DotNetUtils.dll</HintPath>
+    </Reference>
+    <Reference Include="SAGA.RevitAPI">
+      <HintPath>..\Dlls\SAGA.RevitAPI.dll</HintPath>
     </Reference>
     <Reference Include="SAGA.RevitUtils">
       <HintPath>..\Dlls\SAGA.RevitUtils.dll</HintPath>

+ 3 - 0
JBIM/RevitToJBim/TestExport.cs

@@ -13,6 +13,7 @@ using System.Text;
 using System.Threading.Tasks;
 using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
 using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using RevitExport;
@@ -28,6 +29,8 @@ namespace RevitToJBim
         public static void Export()
         {
             var elements = Document.GetElements(typeof(Pipe));
+            var elements2 = Document.GetElements(typeof(SpatialElement)).OfType<Space>().ToList();
+            elements.AddRange(elements2);
             var wrappers = elements.Select(e => new ElementWrapper(e)).ToList();
             ExportInstance report = new ExportInstance(wrappers);
             JBimParseContext context = new JBimParseContext(ParseCore.GetUseParsers());

BIN
JBIM/RevitToJBim/bin/Debug/JBIM.dll


BIN
JBIM/RevitToJBim/bin/Debug/JBIM.pdb


BIN
JBIM/RevitToJBim/bin/Debug/RevitToJBim.dll


BIN
JBIM/RevitToJBim/bin/Debug/RevitToJBim.pdb


BIN
JBIM/RevitToJBim/bin/Debug/SAGA.DotNetUtils.dll


BIN
JBIM/RevitToJBim/bin/Debug/SAGA.RevitAPI.dll


BIN
JBIM/RevitToJBim/bin/Debug/SAGA.RevitUtility.dll


BIN
JBIM/RevitToJBim/bin/Debug/SAGA.RevitUtils.dll