|
@@ -0,0 +1,108 @@
|
|
|
+/*-------------------------------------------------------------------------
|
|
|
+ * 功能描述:ParseDuct
|
|
|
+ * 作者:xulisong
|
|
|
+ * 创建时间: 2019/6/20 9:40:13
|
|
|
+ * 版本号:v1.0
|
|
|
+ * -------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Autodesk.Revit.DB;
|
|
|
+using Autodesk.Revit.DB.Mechanical;
|
|
|
+using Autodesk.Revit.DB.Plumbing;
|
|
|
+using JBIM;
|
|
|
+using RevitExport;
|
|
|
+using RevitToJBim.Common;
|
|
|
+using SAGA.RevitUtils.Extends;
|
|
|
+using SAGA.RevitUtils.MEP;
|
|
|
+using JDuctShape = JBIM.DuctShape;
|
|
|
+using JDuct = JBIM.Component.Duct;
|
|
|
+using XYZ = JBIM.XYZ;
|
|
|
+
|
|
|
+namespace RevitToJBim.ComponentParse
|
|
|
+{
|
|
|
+ [UsableParse]
|
|
|
+ public class ParseDuct : ParseBase
|
|
|
+ {
|
|
|
+ public override List<string> FastIndex()
|
|
|
+ {
|
|
|
+ return new List<string>() { typeof(Duct).FullName };
|
|
|
+ }
|
|
|
+ public override bool Match(ElementWrapper wrapper)
|
|
|
+ {
|
|
|
+ return wrapper.RefElement is Duct;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
|
|
|
+ {
|
|
|
+ if (!(wrapper.RefElement is Duct duct))
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JDuct jDuct = new JDuct();
|
|
|
+ ParseCore.AttachObject(jDuct, wrapper);
|
|
|
+ var locations = new List<XYZ>();
|
|
|
+ locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().StartPoint()));
|
|
|
+ locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().EndPoint()));
|
|
|
+ jDuct.Location = GeometryLocation.CreateLineLocation(locations);
|
|
|
+ Polygon outLine = new Polygon(locations);
|
|
|
+ jDuct.OutLine.Add(outLine);
|
|
|
+ context.AddBimObject(jDuct);
|
|
|
+ #region 关联数据处理相关
|
|
|
+ #region 系统关系
|
|
|
+ var pipeId = duct.Id.ToString();
|
|
|
+ var systemTypeName = duct.Document.GetElement(duct.MEPSystem.GetTypeId());
|
|
|
+ jDuct.MepSystemTypeName = systemTypeName.Name;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ ConnectorProfileType shape = ConnectorProfileType.Invalid;
|
|
|
+ #region Connector连接关系
|
|
|
+ var connectors = duct.GetConnectors(Autodesk.Revit.DB.Domain.DomainHvac);
|
|
|
+ ElementOneToManyRel relMany = new ElementOneToManyRel(pipeId) { RelatedObjects = new List<string>() };
|
|
|
+ relMany.SetElementType(TypeDefinition.Property_ConnectedIds);
|
|
|
+ foreach (var refConnector in connectors)
|
|
|
+ {
|
|
|
+ relMany.RelatedObjects.Add(RevitIdGenerator.GetConnectorId(refConnector));
|
|
|
+ shape = refConnector.Shape;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (relMany.RelatedObjects.Any())
|
|
|
+ {
|
|
|
+ context.RelationShips.Add(relMany);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ if (shape== ConnectorProfileType.Round)
|
|
|
+ {//duct.
|
|
|
+ jDuct.Diameter = duct.Diameter.FtToUse();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jDuct.Width = duct.Width.FtToUse();
|
|
|
+ jDuct.Height = duct.Height.FtToUse();
|
|
|
+ }
|
|
|
+
|
|
|
+ jDuct.Shape = (JDuctShape) (int) shape;
|
|
|
+ #endregion
|
|
|
+ return new List<BimId>() { jDuct.Id };
|
|
|
+ }
|
|
|
+
|
|
|
+ public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
|
|
|
+ {
|
|
|
+ if (!(wrapper.RefElement is Duct duct))
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ var wrappers = new List<ElementWrapper>() { };
|
|
|
+ var connectors = duct.GetConnectors(Autodesk.Revit.DB.Domain.DomainHvac);
|
|
|
+ foreach (var connector in connectors)
|
|
|
+ {
|
|
|
+ wrappers.Add(ParseCore.GetConnectorWrapper(connector));
|
|
|
+ }
|
|
|
+ return wrappers;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|