123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /*-------------------------------------------------------------------------
- * 功能描述:ParseSpace
- * 作者:xulisong
- * 创建时间: 2019/6/17 14:28:03
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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;
- using JBIM.Definition;
- using RevitExport.Export;
- using RevitToJBim.ParseData;
- namespace RevitToJBim.ComponentParse
- {
- [UsableParse]
- public class ParseSpace : ParseBase
- {
- public override List<string> FastIndex()
- {
- return new List<string>() {typeof(Space).FullName};
- }
- public override bool Match(ElementWrapper wrapper)
- {
- return wrapper.RefElement is Space;
- }
- protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
- {
- if (!(wrapper.RefElement is Space space))
- {
- return null;
- }
- //if (!space.IsSpace())
- //{
- // return null;
- //}
- JSpace bimObject = new JSpace();
- ParseCore.AttachObject(bimObject, wrapper);
- var location = space.Location.GetPoint();
- if (location != null)
- {
- bimObject.Location =
- GeometryLocation.CreatePointLocation(BimConvert.ConvertToXYZ(location));
- }
- //Parameters
- bimObject.Parameters = RevitUtil.GetSpaceParameters(space);
- 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())
- {
- StandardUtil.ArrangeLoop(outLine);
- bimObject.OutLine.Add(outLine);
- }
- if (segmentBimids.Any())
- {
- bimObject.BoundarySegments.Add(segmentBimids);
- }
- }
- }
-
- context.AddBimObject(bimObject);
- return new List<BimId>();
- }
- }
- }
|