|
@@ -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>();
|
|
|
}
|
|
|
}
|
|
|
}
|