123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /*-------------------------------------------------------------------------
- * 功能描述: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 JBIM.Definition;
- using RevitExport;
- using RevitExport.Export;
- using RevitToJBim.Common;
- using RevitToJBim.ParseData;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- using JDuctShape = JBIM.Definition.DuctShape;
- using JDuct = JBIM.Component.Duct;
- using XYZ = JBIM.Definition.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;
- }
- }
- }
|