1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /*-------------------------------------------------------------------------
- * 功能描述:ParseFamilyJoinObject
- * 作者:xulisong
- * 创建时间: 2019/6/24 9:29:00
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using JBIM;
- using JBIM.Component;
- using JBIM.Definition;
- using RevitExport.Export;
- using RevitToJBim.Common;
- using RevitToJBim.Extension;
- using JFamilyType=RevitToJBim.Common.FamilyType;
- using RevitToJBim.ParseData;
- using SAGA.DotNetUtils.Extend;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- namespace RevitToJBim.ComponentParse
- {
- [UsableParse]
- public class ParseJoinObject : ParseBase
- {
- public override List<string> FastIndex()
- {
- return new List<string>() { CategoryGenerator .BuildingCategory(JFamilyType.JoinObject)};
- }
- public override bool Match(ElementWrapper wrapper)
- {
- return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.JoinObject);
- }
- protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
- {
- if (!(wrapper.RefElement is FamilyInstance familyInstance))
- {
- return null;
- }
- //ElementType
- OtherJoinObject jObject = new OtherJoinObject();
- //Name,SourceId
- ParseCore.AttachObject(jObject, wrapper);
- //FamilyName
- jObject.FamilyName = familyInstance.GetFamilyName();
- jObject.FamilySymbol = familyInstance.GetFamilySymbolName();
- //Location
- jObject.Location = GeometryLocation.CreatePointLocation(BimConvert.ConvertToXYZ(familyInstance.GetLocationPoint()));
- jObject.Rotation = familyInstance.GetRotation().ToAngle().Round(2);
- //OutLine
- var polygonPath = RevitUtil.GetBottomPolygon(familyInstance);
- if (polygonPath != null && polygonPath.Any())
- {
- Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
- jObject.OutLine.Add(outLine);
- }
- //Id
- context.AddBimObject(jObject);
- #region Connector连接关系
- var connectors = familyInstance.GetAllConnectors();
- if (connectors.Any())
- {
- ElementOneToManyRel relMany = ParseCore.GetConnectorRels(familyInstance,connectors);
- context.RelationShips.Add(relMany);
- }
- #endregion
- return new List<BimId>() { jObject.Id };
- }
- public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
- {
- if (!(wrapper.RefElement is FamilyInstance fi))
- {
- return null;
- }
- var wrappers = new List<ElementWrapper>() { };
- var connectors = fi.GetAllConnectors();
- foreach (var connector in connectors)
- {
- wrappers.Add(ParseCore.GetConnectorWrapper(connector));
- }
- return wrappers;
- }
- }
- }
|