Пример #1
0
        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);
            }
        }
Пример #2
0
        protected void SetSpaces(List <FamilyInstance> allPlunts)
        {
            var log = LoggingMachine.NewLog("Назначение пространств", allPlunts, "Оборудование не находится в пространстве");

            UI.ProgressBar pBar = new UI.ProgressBar("Назначение пространств", allPlunts.Count);
            // Назначаем номера помещений диффузорам
            foreach (FamilyInstance el in allPlunts)
            {
                Parameter p     = el.LookupParameter(spaceNumberParameterName);
                Space     space = GetSpaceOfPlant(el);
                if (space != null)
                {
                    string roomNumber = space.LookupParameter("Номер").AsString();
                    p.Set(roomNumber);
                }
                else
                {
                    p.Set("<Помещение не найдено!>");
                    log.FailedElementIds.Push(el.Id.ToString());
                }
                pBar.StepUp();
            }
        }
Пример #3
0
        private void UpdatePluntSystem(List <FamilyInstance> allPlunts, ref List <FamilyInstance> failedPlunts)
        {
            UI.ProgressBar pBar = new UI.ProgressBar("Назначение систем", allPlunts.Count);
            foreach (FamilyInstance plunt in allPlunts)
            {
                Space  space      = GetSpaceOfPlant(plunt);
                string systemName = null;
                if (space != null)
                {
                    string systemTypeName  = plunt.get_Parameter(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM).AsValueString();
                    string systemClassName = plunt.get_Parameter(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM).AsString();
                    if (systemTypeName == suplySystemTypeName)
                    {
                        systemName = space.LookupParameter(supplySystemParameterName).AsString();
                    }
                    else if (systemTypeName == exhaustSystemTypeName)
                    {
                        systemName = space.LookupParameter(exhaustSystemParameterName).AsString();
                    }

                    /*else if (systemTypeName == "Не определено")
                     * {
                     *  if (systemClassName == "Приточный воздух") systemName = space.LookupParameter(supplySystemParameterName).AsString();
                     *  else if (systemClassName == "Отработанный воздух") systemName = space.LookupParameter(exhaustSystemParameterName).AsString();
                     * }*/
                    if (systemName != null)
                    {
                        ConnectorSet connectors    = plunt.MEPModel.ConnectorManager.Connectors;
                        Connector    baseConnector = connectors.Cast <Connector>().FirstOrDefault();
                        MEPSystem    fromSystem    = baseConnector?.MEPSystem;
                        MEPSystem    toSystem      = new FilteredElementCollector(doc).OfClass(typeof(MEPSystem)).Cast <MEPSystem>().Where(x => x.Name == systemName).FirstOrDefault();
                        if (fromSystem?.Id.IntegerValue == toSystem?.Id.IntegerValue)
                        {
                            continue;
                        }
                        if (fromSystem == null && toSystem == null)
                        {
                            DuctSystemType ductType = DuctSystemType.UndefinedSystemType;
                            if (systemTypeName == suplySystemTypeName)
                            {
                                ductType = DuctSystemType.SupplyAir;
                            }
                            else if (systemTypeName == exhaustSystemTypeName)
                            {
                                ductType = DuctSystemType.ExhaustAir;
                            }
                            toSystem      = doc.Create.NewMechanicalSystem(null, connectors, ductType);
                            toSystem.Name = systemName;
                        }
                        else if (fromSystem == null && toSystem != null)
                        {
                            toSystem.Add(connectors);
                        }
                        else if (fromSystem != null && toSystem == null)
                        {
                            fromSystem.Name = systemName;
                        }
                        else if (fromSystem != null && toSystem != null)
                        {
                            try
                            {
                                if (fromSystem.ConnectorManager.Connectors.Size > 1)
                                {
                                    ConnectorSet smallSet = new ConnectorSet();
                                    smallSet.Insert(baseConnector);
                                    fromSystem.Remove(smallSet);
                                    toSystem.Add(smallSet);
                                }
                                else
                                {
                                    failedPlunts.Add(plunt);
                                }
                            }
                            catch (Autodesk.Revit.Exceptions.ArgumentException)
                            {
                                failedPlunts.Add(plunt);
                            }
                            finally { pBar.StepUp(); }
                        }
                    }
                    else
                    {
                        failedPlunts.Add(plunt);
                    }
                }
                pBar.StepUp();
            }
        }
Пример #4
0
        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();
        }
Пример #5
0
        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();
        }