/*------------------------------------------------------------------------- * 功能描述: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 FastIndex() { return new List() { CategoryGenerator .BuildingCategory(JFamilyType.JoinObject)}; } public override bool Match(ElementWrapper wrapper) { return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.JoinObject); } protected override List 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() { jObject.Id }; } public override List ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context) { if (!(wrapper.RefElement is FamilyInstance fi)) { return null; } var wrappers = new List() { }; var connectors = fi.GetAllConnectors(); foreach (var connector in connectors) { wrappers.Add(ParseCore.GetConnectorWrapper(connector)); } return wrappers; } } }