public List <IntersectionMepCurve> GetIntersections() { linkedDocInstance = DocumentUtils.ChooseLinkedDoc(doc); if (linkedDocInstance == null) { return(new List <IntersectionMepCurve>()); } else { var progress = new UI.ProgressBar("Поиск пересечений...", hosts.Count()); Transform tr = DocumentUtils.GetCorrectionTransform(linkedDocInstance); List <IntersectionMepCurve> intersectionList = new List <IntersectionMepCurve>(); foreach (HostObject host in hosts) { List <Face> hostFaces = GeometryUtils.GetFaces(host); if (hostFaces.Count > 0) { BoundingBoxXYZ bb = host.get_BoundingBox(null); Outline outline = new Outline(tr.OfPoint(bb.Min), tr.OfPoint(bb.Max)); BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(outline); List <MEPCurve> meps = new FilteredElementCollector(linkedDoc) .OfClass(typeof(MEPCurve)) .WherePasses(filter) .Cast <MEPCurve>() .ToList(); foreach (MEPCurve m in meps) { Curve mepCurve = GeometryUtils.FindDuctCurve(m.ConnectorManager); if (mepCurve != null) { XYZ[] interPts = (from wallFace in hostFaces select FindFaceIntersection(mepCurve, wallFace)).ToArray(); if (interPts.Any(x => x != null)) { XYZ pt = interPts.First(x => x != null); try { IntersectionMepCurve i = new IntersectionMepCurve(host, m, pt, linkedDocInstance); intersectionList.Add(i); } catch (NotImplementedException) { } } } } } progress.StepUp(); } progress.Close(); return(intersectionList); } }
private void UpdatePluntData(List <FamilyInstance> allPlunts, ref List <FamilyInstance> failedPlunts) { const int upperZoneHeight = 1800; UI.ProgressBar pBar = new UI.ProgressBar("Назначение расхода", allPlunts.Count); foreach (FamilyInstance plunt in allPlunts) { try { // Параметр номера помещения Parameter spaceNumberParam = plunt.LookupParameter(spaceNumberParameterName); // Параметр Расход воздуха Parameter airflowParam = plunt.LookupParameter(airflowParameterName); // Параметр "Классификация системы" BuiltInParameter sysTypeBuiltIn = BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM; Parameter systemTypeParam = plunt.get_Parameter(sysTypeBuiltIn); string systemType = systemTypeParam.AsValueString(); // Считаем количество диффузоров одной системы на пространство int countUpperZone = (from d in allPlunts where d.LookupParameter(spaceNumberParameterName).AsString() == spaceNumberParam.AsString() && d.get_Parameter(sysTypeBuiltIn).AsValueString() == systemType && UnitUtils.ConvertFromInternalUnits(d.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).AsDouble(), DisplayUnitType.DUT_MILLIMETERS) >= upperZoneHeight select d).Count(); int countBottomZone = (from d in allPlunts where d.LookupParameter(spaceNumberParameterName).AsString() == spaceNumberParam.AsString() && d.get_Parameter(sysTypeBuiltIn).AsValueString() == systemType && UnitUtils.ConvertFromInternalUnits(d.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).AsDouble(), DisplayUnitType.DUT_MILLIMETERS) < upperZoneHeight select d).Count(); // Смещение bool isInUpperZone = UnitUtils.ConvertFromInternalUnits(plunt.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).AsDouble(), DisplayUnitType.DUT_MILLIMETERS) >= upperZoneHeight; // Находим пространство, в котором находится диффузор и достаем нужные значения Space space = GetSpaceOfPlant(plunt); if (space != null) { // Задаем расход диффузорам double value = 0; if (systemType == suplySystemTypeName) { value = space.get_Parameter(BuiltInParameter.ROOM_DESIGN_SUPPLY_AIRFLOW_PARAM).AsDouble(); } else if (systemType == exhaustSystemTypeName) { value = space.get_Parameter(BuiltInParameter.ROOM_DESIGN_EXHAUST_AIRFLOW_PARAM).AsDouble(); } // делим на количество диффузоров нужной системы, расположенных в одной вертикальной зоне if (countUpperZone == 0 || countBottomZone == 0) { value = countUpperZone != 0 ? value / countUpperZone : value / countBottomZone; } else { value = isInUpperZone ? value / countUpperZone : value / countBottomZone; } airflowParam.Set(value); } } catch { failedPlunts.Add(plunt); } finally { pBar.StepUp(); } } pBar.Close(); }
private void UpdatePluntGeometry(List <FamilyInstance> allPlunts, ref List <FamilyInstance> failedPlunts) { UI.ProgressBar pBar = new UI.ProgressBar("Назначение размера", allPlunts.Count); // Перечень допустимых размеров int[][] rectOpts = { new int[] { 150, 100 }, new int[] { 200, 100 }, new int[] { 150, 150 }, new int[] { 200, 150 }, new int[] { 250, 150 }, new int[] { 300, 150 }, new int[] { 250, 200 }, new int[] { 250, 250 }, new int[] { 300, 250 }, new int[] { 300, 300 }, new int[] { 350, 300 }, new int[] { 400, 400 }, new int[] { 450, 450 }, new int[] { 500, 500 }, }; int[] roundOpts = { 100, 125, 160, 200 }; foreach (var plunt in allPlunts) { try { // достаем назначенный расход double airflow = plunt.LookupParameter("ADSK_Расход воздуха").AsDouble(); string pluntSystemType = plunt.get_Parameter(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM).AsValueString(); airflow = UnitUtils.ConvertFromInternalUnits(airflow, DisplayUnitType.DUT_CUBIC_METERS_PER_HOUR); Connector connector = plunt.MEPModel.ConnectorManager.Connectors.Cast <Connector>().First(); switch (connector.Shape) { // Круглый диффузоры case ConnectorProfileType.Round: Parameter diamParam = plunt.LookupParameter("ADSK_Размер_Диаметр"); // Приточка if (pluntSystemType == suplySystemTypeName) { if (airflow <= 50) { diamParam.Set(UnitUtils.ConvertToInternalUnits(100, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 100) { diamParam.Set(UnitUtils.ConvertToInternalUnits(125, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 160) { diamParam.Set(UnitUtils.ConvertToInternalUnits(160, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 250) { diamParam.Set(UnitUtils.ConvertToInternalUnits(200, DisplayUnitType.DUT_MILLIMETERS)); } else { failedPlunts.Add(plunt); } } // Вытяжка else if (pluntSystemType == exhaustSystemTypeName) { if (airflow <= 80) { diamParam.Set(UnitUtils.ConvertToInternalUnits(100, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 125) { diamParam.Set(UnitUtils.ConvertToInternalUnits(125, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 160) { diamParam.Set(UnitUtils.ConvertToInternalUnits(160, DisplayUnitType.DUT_MILLIMETERS)); } else if (airflow <= 300) { diamParam.Set(UnitUtils.ConvertToInternalUnits(200, DisplayUnitType.DUT_MILLIMETERS)); } else { failedPlunts.Add(plunt); } } break; // Прямоугольная решетка case ConnectorProfileType.Rectangular: if (pluntSystemType == suplySystemTypeName || pluntSystemType == exhaustSystemTypeName) { Parameter lengthParam = plunt.LookupParameter("ADSK_Размер_Ширина"); Parameter heightParam = plunt.LookupParameter("ADSK_Размер_Высота"); bool found = false; foreach (int[] size in rectOpts) { double F = size[0] * size[1] * 0.68 / 1000000; double V = airflow / (3600 * F); if (V < 3) { lengthParam.Set(UnitUtils.ConvertToInternalUnits(size[0], DisplayUnitType.DUT_MILLIMETERS)); heightParam.Set(UnitUtils.ConvertToInternalUnits(size[1], DisplayUnitType.DUT_MILLIMETERS)); found = true; break; } } if (!found) { failedPlunts.Add(plunt); } } break; default: failedPlunts.Add(plunt); break; } } catch (Autodesk.Revit.Exceptions.InvalidObjectException ex) { failedPlunts.Add(plunt); } finally { pBar.StepUp(); } } pBar.Close(); }