Exemple #1
0
        public static string SizeLookup(FamilySizeTable fmt, string columnName, string[] args)
        {
            int columnIndex = -1;

            for (int i = 0; i < fmt.NumberOfColumns; i++)
            {
                if (fmt.GetColumnHeader(i).Name == columnName)
                {
                    columnIndex = i;
                }
            }
            if (columnIndex != -1)
            {
                for (int i = 0; i < fmt.NumberOfRows; i++)
                {
                    bool   flag = true;
                    string value;
                    for (int j = 0; j < args.Length; j++)
                    {
                        value = fmt.AsValueString(i, j + 1);
                        flag  = flag && value.StartsWith(args[j]);
                    }
                    if (flag)
                    {
                        return(fmt.AsValueString(i, columnIndex));
                    }
                }
            }
            return(null);
        }
Exemple #2
0
        protected void UpdatePluntGeometry(List <FamilyInstance> allPlunts)
        {
            // logging
            ElementProcessingLog lostParameterLog = LoggingMachine.NewLog("Обновление геометрии радиаторов", allPlunts, "В семействе отсутствуют необходимые параметры");
            ElementProcessingLog highWattLog      = LoggingMachine.NewLog("Обновление геометрии радиаторов", allPlunts, "Ни один из вариантов не подходит под такую нагрузку");
            ElementProcessingLog invalidTableLog  = LoggingMachine.NewLog(
                "Обновление геометрии радиаторов", allPlunts, "В таблица выбора отсутствуют подходящие значения", "Проверьте соответствии таблицы выбора и настроек плагина");

            foreach (FamilyInstance plunt in allPlunts)
            {
                Space space = GetSpaceOfPlant(plunt);
                if (space == null)
                {
                    continue;
                }
                int    count         = allPlunts.Where(x => x.LookupParameter("ТеррНИИ_Номер помещения").AsString() == space.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString()).Count();
                double requiredValue = space.get_Parameter(BuiltInParameter.ROOM_DESIGN_HEATING_LOAD_PARAM).AsDouble() / count;
                plunt.LookupParameter(spacePowerParameterName).Set(requiredValue); // для проверки найденных типораразмеров
                requiredValue = UnitUtils.ConvertFromInternalUnits(requiredValue, DisplayUnitType.DUT_WATTS);

                FamilySizeTableManager sizeMng = FamilySizeTableManager.GetFamilySizeTableManager(doc, plunt.Symbol.Family.Id);
                Parameter tableNameParam       = plunt.Symbol.LookupParameter("Таблица выбора");
                Parameter TzParam      = plunt.LookupParameter("ТеррНИИ_Температура подачи");
                Parameter TpParam      = plunt.LookupParameter("ТеррНИИ_Температура обратки");
                Parameter TiParam      = plunt.LookupParameter("ADSK_Температура в помещении");
                Parameter hParam       = plunt.LookupParameter("ADSK_Размер_Высота");
                Parameter lParam       = plunt.LookupParameter("ADSK_Размер_Длина");
                Parameter radTypeParam = plunt.LookupParameter("ТеррНИИ_Тип радиатора");

                if (hParam == null || lParam == null || radTypeParam == null || TzParam == null ||
                    TpParam == null || TiParam == null || sizeMng == null || tableNameParam == null)
                {
                    lostParameterLog.FailedElementIds.Push(plunt.Id.ToString());
                    continue;
                }

                double          Tz        = UnitUtils.ConvertFromInternalUnits(TzParam.AsDouble(), DisplayUnitType.DUT_CELSIUS);
                double          Tp        = UnitUtils.ConvertFromInternalUnits(TpParam.AsDouble(), DisplayUnitType.DUT_CELSIUS);
                double          Ti        = UnitUtils.ConvertFromInternalUnits(TiParam.AsDouble(), DisplayUnitType.DUT_CELSIUS);
                FamilySizeTable sizeTable = sizeMng.GetSizeTable(plunt.Symbol.LookupParameter("Таблица выбора").AsString());

                string sN, sQn, sTzn, sTpn, sTin;
                double N, Qn, Tzn, Tpn, Tin, powerValue;
                bool   wattFinded = false;
                bool   rowFinded  = false;

                Parameter keepHeightParam = plunt.LookupParameter("Не изменять высоту");
                Parameter keepLengthParam = plunt.LookupParameter("Не изменять длину");
                Parameter keepTypeParam   = plunt.LookupParameter("Не изменять тип");
                var       iteratedHeights = keepHeightParam != null && keepHeightParam.AsInteger() == 1
                    ?
                                            new List <int>()
                {
                    Convert.ToInt32(UnitUtils.ConvertFromInternalUnits(hParam.AsDouble(), DisplayUnitType.DUT_MILLIMETERS))
                }
                    :
                TerrSettings.RadiatorHeights;
                var iteratedLengths = keepLengthParam != null && keepLengthParam.AsInteger() == 1
                    ?
                                      new List <int>()
                {
                    Convert.ToInt32(UnitUtils.ConvertFromInternalUnits(lParam.AsDouble(), DisplayUnitType.DUT_MILLIMETERS))
                }
                    :
                TerrSettings.RadiatorLengths;
                var iteratedTypes = keepTypeParam != null && keepTypeParam.AsInteger() == 1
                    ?
                                    new List <int>()
                {
                    radTypeParam.AsInteger()
                }
                    :
                TerrSettings.RadiatorTypes;

                for (int t = 0; t < iteratedTypes.Count() && !wattFinded; t++)
                {
                    int type = iteratedTypes[t];
                    for (int h = 0; h < iteratedHeights.Count() && !wattFinded; h++)
                    {
                        int height = iteratedHeights[h];
                        sN   = FamilyInstanceUtils.SizeLookup(sizeTable, "N", new string[] { type.ToString(), height.ToString() });
                        sQn  = FamilyInstanceUtils.SizeLookup(sizeTable, "Qn", new string[] { type.ToString(), height.ToString() });
                        sTzn = FamilyInstanceUtils.SizeLookup(sizeTable, "Tz", new string[] { type.ToString(), height.ToString() });
                        sTpn = FamilyInstanceUtils.SizeLookup(sizeTable, "Tp", new string[] { type.ToString(), height.ToString() });
                        sTin = FamilyInstanceUtils.SizeLookup(sizeTable, "Ti", new string[] { type.ToString(), height.ToString() });
                        if (sN == null || sQn == null || sTzn == null || sTpn == null || sTin == null)
                        {
                            continue;
                        }
                        rowFinded = true;

                        N   = double.Parse(sN, System.Globalization.CultureInfo.InvariantCulture);
                        Qn  = double.Parse(sQn, System.Globalization.CultureInfo.InvariantCulture);
                        Tzn = double.Parse(sTzn, System.Globalization.CultureInfo.InvariantCulture);
                        Tpn = double.Parse(sTpn, System.Globalization.CultureInfo.InvariantCulture);
                        Tin = double.Parse(sTin, System.Globalization.CultureInfo.InvariantCulture);

                        for (int l = 0; l < iteratedLengths.Count() && !wattFinded; l++)
                        {
                            int length = iteratedLengths[l];
                            powerValue = (length / 1000.0) * Qn * Math.Pow(
                                (
                                    (Tz - Tp)
                                    /
                                    Math.Log((Tz - Ti) / (Tp - Ti))
                                ) / (
                                    (Tzn - Tpn)
                                    /
                                    Math.Log((Tzn - Tin) / (Tpn - Tin))
                                    ),
                                N
                                );

                            if (powerValue >= requiredValue)
                            {
                                lParam.Set(UnitUtils.ConvertToInternalUnits(length, DisplayUnitType.DUT_MILLIMETERS));
                                hParam.Set(UnitUtils.ConvertToInternalUnits(height, DisplayUnitType.DUT_MILLIMETERS));
                                radTypeParam.Set(type);
                                wattFinded = true;
                            }
                        }
                    }
                }
                if (!rowFinded)
                {
                    invalidTableLog.FailedElementIds.Push(plunt.Id.ToString());
                }
                else if (!wattFinded)
                {
                    highWattLog.FailedElementIds.Push(plunt.Id.ToString());
                }
            }
        }