public static void beginCommand(Document doc, ElementSet elems)
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            helper.initialize(doc, elems, helper.Domain);
            invokeCommand(doc, helper, false);
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || sections == null || !needToWrite())
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            writer.addTitleRow(ReportResource.fittingDetailInfo);

            //fitting title
            List <string> strFittingFields = new List <string>();

            getFields(strFittingFields);
            DataTable tbTitle = new DataTable();

            helper.getTableTitle(tbTitle, strFittingFields);
            writer.AddData(tbTitle, 1);

            foreach (MEPSection section in sections)
            {
                DataTable tb = new DataTable();
                if (getFittingInfo(section, tb))
                {
                    writer.AddData(tb, 1);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public PressureLossReportFormats getAllFormats(bool bCheckDomain = true)
        {
            XmlSerializer             serializer = new XmlSerializer(typeof(PressureLossReportFormats));
            PressureLossReportFormats formats    = new PressureLossReportFormats();

            if (!File.Exists(formatFileName))
            {
                return(null);
            }

            using (TextReader reader = new StreamReader(formatFileName))
            {
                try
                {
                    PressureLossReportHelper  helper     = PressureLossReportHelper.instance;
                    PressureLossReportFormats allformats = serializer.Deserialize(reader) as PressureLossReportFormats;
                    if (allformats != null)
                    {
                        foreach (PressureLossReportData data in allformats)
                        {
                            if ((bCheckDomain && data.Domain == helper.Domain) || !bCheckDomain)
                            {
                                formats.Add(data);
                            }
                        }
                    }

                    return(formats);
                }
                catch (System.InvalidOperationException)
                {
                    return(formats);
                }
            }
        }
        private string getFittingSymbolInfoByParamName(FamilyInstance fitting, string paramName)
        {
            string paramVal = ReportConstants.emptyValue;

            if (fitting == null || paramName == null)
            {
                return(paramVal);
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return(paramVal);
            }

            FamilySymbol famSym = fitting.Symbol;

            if (famSym != null)
            {
                paramVal = helper.getFamilyOrTypeName(fitting.Id, paramName);
                if (paramVal == null || paramVal.Length < 1)
                {
                    paramVal = helper.getParamValue(famSym.get_Parameter(paramName));
                }
            }

            return(paramVal);
        }
        private string getSegmentTypeInfoByParamName(MEPCurve crv, string paramName)
        {
            string paramVal = "";

            if (crv == null || paramName == null)
            {
                return(paramVal);
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return(paramVal);
            }

            MEPCurveType crvType = helper.Doc.GetElement(crv.GetTypeId()) as MEPCurveType;

            if (crvType != null)
            {
                paramVal = helper.getFamilyOrTypeName(crv.Id, paramName);
                if (paramVal == null || paramVal.Length < 1)
                {
                    paramVal = helper.getParamValue(crvType.get_Parameter(paramName));
                }
            }

            return(paramVal);
        }
        public bool getSectionInfo(MEPSection section, DataTable sectionTB, bool forHTML = false)
        {
            if (section == null || sectionTB == null)
            {
                return(false);
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return(false);
            }

            PressureLossReportData reportData = helper.ReportData;

            if (reportData == null)
            {
                return(false);
            }

            List <string> sectionFields = new List <string>();

            getFields(sectionFields);

            getSectionTable(section, sectionTB, sectionFields, reportData, forHTML);

            return(true);
        }
        public static void beginCommand(Document doc, string strDomain, bool bForAllSystems = false, bool bFitlerUnCalculationSystems = false)
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;
            UIDocument uiDocument           = new UIDocument(doc);

            if (bFitlerUnCalculationSystems)
            {
                ElementSet calculationOnElems = new ElementSet();
                int        nTotalCount        = getCalculationElemSet(doc, strDomain, calculationOnElems, uiDocument.Selection.Elements);

                if (calculationOnElems.Size == 0)
                {//No item can be calculated
                    popupWarning(ReportResource.allItemsCaculationOff, TaskDialogCommonButtons.Close, TaskDialogResult.Close);
                    return;
                }
                else if (calculationOnElems.Size < nTotalCount)
                {//Part of them can be calculated
                    if (popupWarning(ReportResource.partOfItemsCaculationOff, TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes, TaskDialogResult.Yes) == TaskDialogResult.No)
                    {
                        return;
                    }
                }

                helper.initialize(doc, calculationOnElems, strDomain);
                invokeCommand(doc, helper, bForAllSystems);
            }
            else
            {
                helper.initialize(doc, uiDocument.Selection.Elements, strDomain);
                invokeCommand(doc, helper, bForAllSystems);
            }
        }
        public override void writeToHTML(HtmlStreamWriter writer)
        {
            if (writer == null || sections == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            //section title
            List <string> strSectionFields = new List <string>();

            getFields(strSectionFields);
            writer.WriteElementString("SectionInfoTitle", ReportResource.sectionTitle);
            writer.writeTableTitle("Section", strSectionFields, true);

            //section info
            foreach (MEPSection section in sections)
            {
                string    str          = "Section";
                DataTable detailInfoTB = new DataTable("SectionDetailInfo");
                bool      bTable       = getSectionInfo(section, detailInfoTB, true);
                string    totalPL      = helper.getTotalPressureLossByType(section, SectionMemberType.Section);

                if (bTable)
                {
                    writer.writeTable(str, detailInfoTB, section.Number.ToString(), totalPL);
                }
            }
        }
        private bool hasFittingsInSystem()
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return(false);
            }
            //find the first fitting
            List <MEPSystem> systems = helper.getSortedSystems();

            if (systems == null || systems.Count < 1)
            {
                return(false);
            }
            foreach (MEPSystem system in systems)
            {
                List <MEPSection> sections = new List <MEPSection>();
                MEPSystemInfo.getSectionsFromSystem(system, sections);
                foreach (MEPSection section in sections)
                {
                    //find one section which contains both segment and fitting
                    List <FamilyInstance> fittings = new List <FamilyInstance>();

                    SectionsInfo.getSectionElements(section, null, fittings, null, null);

                    if (fittings.Count > 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #10
0
        public ReportSystemTypeFilterDlg(List <Autodesk.Revit.DB.MEPSystemType> allSysType, List <Autodesk.Revit.DB.MEPSystemType> checkedSysType)
        {
            allValidSystemsType     = allSysType;
            checkedValidSystemsType = checkedSysType;

            InitializeComponent();

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            //title
            if (helper.Domain == ReportResource.pipeDomain)
            {
                this.Text = ReportResource.pipeSystemTypeFilterDlgTitle;
            }
            else
            {
                this.Text = ReportResource.ductSystemTypeFilterDlgTitle;
            }

            FillData();
        }
        private void FillData()
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            if (helper.Domain == ReportResource.ductDomain)
            {
                filterCategories.Add(Autodesk.Revit.DB.BuiltInCategory.OST_DuctSystem);
                this.Text = ReportResource.ductSystemSelectorDlgTitle;
            }
            else if (helper.Domain == ReportResource.pipeDomain)
            {
                filterCategories.Add(Autodesk.Revit.DB.BuiltInCategory.OST_PipingSystem);
                this.Text = ReportResource.pipeSystemSelectorDlgTitle;
            }

            //default add all valid system type to checked system type
            foreach (Autodesk.Revit.DB.BuiltInCategory categoryId in filterCategories)
            {
                ICollection <Autodesk.Revit.DB.Element> founds = helper.getCategoryTypeElements(categoryId);
                foreach (Autodesk.Revit.DB.MEPSystemType sysType in founds)
                {
                    if (helper.isValidSystemType(sysType))
                    {
                        allValidSystemType.Add(sysType);
                    }
                }
            }

            checkedSystemType = helper.getSelectedSystemTypes();
            if (checkedSystemType == null || checkedSystemType.Count < 1)
            {
                if (checkedSystemType == null)
                {
                    checkedSystemType = new List <MEPSystemType>();
                }
                foreach (Autodesk.Revit.DB.MEPSystemType sysType in allValidSystemType)
                {
                    checkedSystemType.Add(sysType);
                }
            }

            //sort the system types
            SortSystemTypeByNameCamparer systemTypeCompare = new SortSystemTypeByNameCamparer();

            checkedSystemType.Sort(systemTypeCompare);
            allValidSystemType.Sort(systemTypeCompare);


            foreach (Autodesk.Revit.DB.BuiltInCategory categoryId in filterCategories)
            {
                ICollection <Autodesk.Revit.DB.Element> founds = helper.getCategoryElements(categoryId);
                addItemsToCheckList(helper, founds);
            }
        }
        static public void getSectionCommonInfo(MEPSection section, Dictionary <string, string> fieldAndValue)
        {
            if (fieldAndValue == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            Document doc = helper.Doc;

            if (doc == null)
            {
                return;
            }

            if (helper.Domain == ReportResource.ductDomain)
            {
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_DUCT_FLOW_PARAM), FormatUtils.Format(doc, UnitType.UT_HVAC_Airflow, section.Flow));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_FRICTION), FormatUtils.Format(doc, UnitType.UT_HVAC_Friction, section.Friction));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_VELOCITY), FormatUtils.Format(doc, UnitType.UT_HVAC_Velocity, section.Velocity));
                fieldAndValue.Add(ReportResource.sectionPressureLoss, FormatUtils.Format(doc, UnitType.UT_HVAC_Pressure, section.TotalPressureLoss));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_VELOCITY_PRESSURE), FormatUtils.Format(doc, UnitType.UT_HVAC_Pressure, section.VelocityPressure));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_REYNOLDSNUMBER_PARAM), FormatUtils.Format(doc, UnitType.UT_Number, section.ReynoldsNumber));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_LOSS_COEFFICIENT), FormatUtils.Format(doc, UnitType.UT_Number, getFittingsLossCoefficient(section)));
            }
            else
            {
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FLOW_PARAM), FormatUtils.Format(doc, UnitType.UT_Piping_Flow, section.Flow));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_FRICTION), FormatUtils.Format(doc, UnitType.UT_Piping_Friction, section.Friction));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_VELOCITY), FormatUtils.Format(doc, UnitType.UT_Piping_Velocity, section.Velocity));
                fieldAndValue.Add(ReportResource.sectionPressureLoss, FormatUtils.Format(doc, UnitType.UT_Piping_Pressure, section.TotalPressureLoss));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_VELOCITY_PRESSURE), FormatUtils.Format(doc, UnitType.UT_Piping_Pressure, section.VelocityPressure));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_REYNOLDS_NUMBER_PARAM), FormatUtils.Format(doc, UnitType.UT_Number, section.ReynoldsNumber));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FRICTION_FACTOR_PARAM), FormatUtils.Format(doc, UnitType.UT_Number, section.FrictionFactor));
                fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_KFACTOR_PARAM), FormatUtils.Format(doc, UnitType.UT_Number, getFittingsLossCoefficient(section)));

                //need to check system type
                if (helper.SystemClassification == MEPSystemClassification.DomesticColdWater ||
                    helper.SystemClassification == MEPSystemClassification.DomesticHotWater ||
                    helper.SystemClassification == MEPSystemClassification.Sanitary)
                {
                    fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FIXTURE_UNITS_PARAM), FormatUtils.Format(doc, UnitType.UT_Number, section.FixtureUnit));
                }
                else
                {
                    fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FIXTURE_UNITS_PARAM), ReportConstants.emptyValue);
                }
            }

            fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_ROUGHNESS_PARAM), FormatUtils.Format(doc, UnitType.UT_Piping_Roughness, section.Roughness));
            fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.CURVE_ELEM_LENGTH), FormatUtils.Format(doc, UnitType.UT_Length, section.TotalCurveLength));
            fieldAndValue.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_SECTION), section.Number.ToString());
        }
        static public string getSectionInfoByParamName(MEPSection section, string paramName, int nGetFrom, ElementId id)
        {
            string paramVal = "";

            if (section == null || paramName == null || (nGetFrom & (int)SectionMemberType.Section) == 0)
            {
                return(paramVal);
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return(paramVal);
            }

            if (paramName == LabelUtils.GetLabelFor(BuiltInParameter.RBS_PRESSURE_DROP) ||
                paramName == ReportResource.pressureLoss)
            {
                double dVal = section.GetPressureDrop(id);

                if (helper.Domain == ReportResource.pipeDomain)
                {
                    paramVal = FormatUtils.Format(helper.Doc, UnitType.UT_Piping_Pressure, dVal);
                }
                else
                {
                    paramVal = FormatUtils.Format(helper.Doc, UnitType.UT_HVAC_Pressure, dVal);
                }
                return(paramVal);
            }
            else if (paramName == LabelUtils.GetLabelFor(BuiltInParameter.RBS_LOSS_COEFFICIENT) ||
                     paramName == LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_KFACTOR_PARAM))
            {
                double dVal = section.GetCoefficient(id);
                paramVal = FormatUtils.Format(helper.Doc, UnitType.UT_Number, dVal);
                return(paramVal);
            }

            else if (paramName == LabelUtils.GetLabelFor(BuiltInParameter.CURVE_ELEM_LENGTH))
            {
                double dVal = section.GetSegmentLength(id);
                paramVal = FormatUtils.Format(helper.Doc, UnitType.UT_Length, dVal);
                return(paramVal);
            }

            Dictionary <string, string> fieldAndValue = new Dictionary <string, string>();

            SectionsInfo.getSectionCommonInfo(section, fieldAndValue);

            if (fieldAndValue.ContainsKey(paramName))
            {
                return(fieldAndValue[paramName]);
            }

            return(paramVal);
        }
        public void getInfoDataTable(DataTable systemTB)
        {
            if (systemTB == null || system == null)
            {
                return;
            }

            systemTB.Columns.Add("SystemInfoName");
            systemTB.Columns.Add("SystemInfoValue");

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            MEPSystemType sysType = helper.Doc.GetElement(system.GetTypeId()) as MEPSystemType;

            if (sysType != null)
            {
                systemTB.Rows.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM), system.get_Parameter(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM).AsString());

                if (helper.Domain == ReportResource.ductDomain)
                {
                    systemTB.Rows.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM), sysType.Name);
                }
                else
                {
                    systemTB.Rows.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPING_SYSTEM_TYPE_PARAM), sysType.Name);
                }
                systemTB.Rows.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_SYSTEM_NAME_PARAM), system.Name);
                systemTB.Rows.Add(LabelUtils.GetLabelFor(BuiltInParameter.RBS_SYSTEM_ABBREVIATION_PARAM), sysType.Abbreviation);

                if (helper.Domain == ReportResource.pipeDomain) // need to list fluid info
                {
                    //Fluid type is an element id
                    ElementId elemId       = sysType.get_Parameter(BuiltInParameter.RBS_PIPE_FLUID_TYPE_PARAM).AsElementId();
                    string    strFluidType = "";
                    if (elemId != null)
                    {
                        Element elem = helper.Doc.GetElement(elemId);
                        if (elem != null)
                        {
                            strFluidType = elem.Name;
                        }
                    }
                    systemTB.Rows.Add(sysType.get_Parameter(BuiltInParameter.RBS_PIPE_FLUID_TYPE_PARAM).Definition.Name, strFluidType);
                    helper.addParameterNameAndValueToTable(systemTB, sysType.get_Parameter(BuiltInParameter.RBS_PIPE_FLUID_TEMPERATURE_PARAM), false);
                    helper.addParameterNameAndValueToTable(systemTB, sysType.get_Parameter(BuiltInParameter.RBS_PIPE_FLUID_VISCOSITY_PARAM), false);
                    helper.addParameterNameAndValueToTable(systemTB, sysType.get_Parameter(BuiltInParameter.RBS_PIPE_FLUID_DENSITY_PARAM), false);
                }
            }

            return;
        }
Пример #15
0
        public ReportFormatNameDlg()
        {
            InitializeComponent();
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }
        }
        public override bool needToWrite()
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper.ReportData == null || helper.ReportData.DisplaySysInfo == false)
            {
                return(false);
            }

            return(true);
        }
        /************************************************************************/

        /* For pipe fitting and accessory, remove coefficient
         *
         *
         */
        /************************************************************************/
        public void upgrade4(PressureLossReportData data, int nVersion = 4)
        {
            if (data == null || data.Version >= nVersion)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            string fieldLossMethodName = LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_METHOD_PARAM);
            string fieldKFactorName    = LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_KFACTOR_PARAM);
            string fieldKTableName     = LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_TABLE_PARAM);

            string fieldNewLossMethodName = LabelUtils.GetLabelFor(BuiltInParameter.RBS_PIPE_FITTING_LOSS_METHOD_SERVER_PARAM);

            int nDisplayOrder = -1;

            if (data.Domain == ReportResource.pipeDomain) //Remove the 3 old parameters for pipe
            {
                PressureLossParameter PLParam1 = helper.getPressureLossParamByName(data.FittingFields, fieldLossMethodName);
                if (PLParam1 != null)
                {
                    nDisplayOrder = PLParam1.DisplayOrder;
                    data.FittingFields.Remove(PLParam1);
                }

                PressureLossParameter PLParam2 = helper.getPressureLossParamByName(data.FittingFields, fieldKFactorName);
                if (PLParam2 != null)
                {
                    data.FittingFields.Remove(PLParam2);
                }

                PressureLossParameter PLParam3 = helper.getPressureLossParamByName(data.FittingFields, fieldKTableName);
                if (PLParam3 != null)
                {
                    data.FittingFields.Remove(PLParam3);
                }

                //Add the new loss method as selected field for pipe
                PressureLossParameter PLParam = new PressureLossParameter(fieldNewLossMethodName, true, nDisplayOrder, (int)SectionMemberType.Fitting);
                if (!data.FittingFields.Contains(PLParam))
                {
                    data.FittingFields.Add(PLParam);
                }
            }

            data.Version = nVersion;
            PressureLossReportDataManager.Instance.save(data);
        }
        public override bool needToWrite()
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper.ReportData == null || helper.ReportData.DisplayDetailInfoForStraightSeg == false || helper.ReportData.StraightSegFields == null)
            {
                return(false);
            }

            return(true);
        }
        public override bool needToWrite()
        {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper.ReportData == null || helper.ReportData.DisplayFittingLCSum == false || helper.ReportData.FittingFields == null)
            {
                return(false);
            }

            return(true);
        }
        private void addItemsToCheckList(PressureLossReportHelper helper, ICollection <Autodesk.Revit.DB.Element> founds)
        {
            //get the selected systems first
            ElementSet selSystems = new ElementSet();

            helper.getSelectedSystems(selSystems);

            List <string> checkedItems = new List <string>();

            foreach (Element elem in selSystems)
            {
                MEPSystem mepSys = elem as MEPSystem;
                if (mepSys == null)
                {
                    continue;
                }

                checkedItems.Add(mepSys.Name);
            }

            List <MEPSystemType> selSystemTypes = helper.getSelectedSystemTypes(true);

            if ((selSystemTypes == null || selSystemTypes.Count < 1) && (checkedItems == null || checkedItems.Count < 1))
            {
                bool bCheckAll = true;
                if (helper.isSelectInValidSystemType())
                {
                    bCheckAll = false;
                }

                addItemsToCheckList(helper, founds, null, bCheckAll);
            }
            else
            {
                foreach (Autodesk.Revit.DB.Element elem in founds)
                {
                    Autodesk.Revit.DB.MEPSystem     mepSysElem = elem as Autodesk.Revit.DB.MEPSystem;
                    Autodesk.Revit.DB.MEPSystemType mepSysType = helper.getSystemType(helper.Doc, mepSysElem);

                    if (isCheckedSystemType(mepSysType) && helper.isValidSystem(helper.Doc, mepSysElem, helper.Domain) && isCalculationOn(helper.Doc, mepSysElem))
                    {
                        if (selSystemTypes != null && PressureLossReportHelper.isSystemTypeInList(selSystemTypes, mepSysType))
                        {
                            checkedItems.Add(mepSysElem.Name);
                        }
                    }
                }

                addItemsToCheckList(helper, founds, checkedItems);
            }
        }
Пример #21
0
 private void addItemsToCheckList(List <Autodesk.Revit.DB.MEPSystemType> allSysType, List <Autodesk.Revit.DB.MEPSystemType> checkedSysType)
 {
     foreach (Autodesk.Revit.DB.MEPSystemType sysType in allSysType)
     {
         if (PressureLossReportHelper.isSystemTypeInList(checkedSysType, sysType))
         {
             SystemTypeCheckList.Items.Add(sysType.Name, true);
         }
         else
         {
             SystemTypeCheckList.Items.Add(sysType.Name, false);
         }
     }
 }
        private void getFields(List <string> fileds)
        {
            if (fileds == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            if (helper.ReportData.AvailableFields != null)
            {
                helper.getFieldsFromReportdata(helper.ReportData.FittingFields, fileds);
            }
        }
        private void generateDefaultFormatData()
        {
            if (settings == null)
            {
                settings = new PressureLossReportData();
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            settings.Domain = helper.Domain;
            settings.DisplayCriticalPath             = true;
            settings.DisplayDetailInfoForStraightSeg = true;
            settings.DisplayFittingLCSum             = true;
            settings.DisplaySysInfo   = true;
            settings.OpenAfterCreated = true;

            //initialize the fields
            helper.generateAviliableFields(settings);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="formatName"></param>
        public void remove(string formatName)
        {
            PressureLossReportFormats formats = getAllFormats(false);

            if (formats != null)
            {
                PressureLossReportHelper helper = PressureLossReportHelper.instance;
                foreach (PressureLossReportData data in formats)
                {
                    if (0 == string.Compare(data.Name, formatName) && helper.Domain == data.Domain)
                    {
                        formats.Remove(data);
                        break;
                    }
                }
                clear();
                save(formats);
            }
        }
        static public string getReportFormatFullName()
        {
            string filename = "";

            try
            {
                PressureLossReportHelper helper = PressureLossReportHelper.instance;
                if (helper == null || helper.Doc == null)
                {
                    return(filename);
                }

                //same location as record journaling (for journal replaying)
                filename = System.IO.Path.GetDirectoryName(helper.Doc.Application.RecordingJournalFilename);
                if (filename != null && filename.Length > 0)
                {
                    string tempName = filename + "\\PressureLossReportFormats.xml";
                    if (tempName != null && tempName.Length > 0 && File.Exists(tempName))
                    {
                        return(tempName);
                    }

                    filename = System.IO.Path.GetDirectoryName(filename + ".xml");
                    filename = filename + "\\PressureLossReportFormats.xml";
                }

                //same location as RevitDB.dll
                if (filename == null || filename.Length < 1 || !File.Exists(filename))
                {
                    string strTempfilename = System.IO.Path.GetDirectoryName(helper.Doc.Application.DefaultProjectTemplate);
                    if (strTempfilename != null && strTempfilename.Length > 0)
                    {
                        filename = strTempfilename + "\\PressureLossReportFormats.xml";
                    }
                }
            }
            catch
            {
                //do nothing
            }
            return(filename);
        }
        private void addItemsToCheckList(PressureLossReportHelper helper, ICollection <Autodesk.Revit.DB.Element> founds, List <string> checkedItems, bool bCheckAll = false)
        {
            SortedDictionary <string, bool> systemList = new SortedDictionary <string, bool>();

            foreach (Autodesk.Revit.DB.Element elem in founds)
            {
                Autodesk.Revit.DB.MEPSystem     mepSysElem = elem as Autodesk.Revit.DB.MEPSystem;
                Autodesk.Revit.DB.MEPSystemType mepSysType = helper.getSystemType(helper.Doc, mepSysElem);

                if (isCheckedSystemType(mepSysType) && helper.isValidSystem(helper.Doc, mepSysElem, helper.Domain) && isCalculationOn(helper.Doc, mepSysElem))
                {
                    if (bCheckAll || (checkedItems != null && checkedItems.Contains(mepSysElem.Name)))
                    {
                        systemList.Add(mepSysElem.Name, true);
                    }
                    else
                    {
                        systemList.Add(mepSysElem.Name, false);
                    }

                    allElementItems.Add(mepSysElem);
                }
            }

            bool bDisabled = true;

            foreach (KeyValuePair <string, bool> kvp in systemList)
            {
                SystemCheckList.Items.Add(kvp.Key, kvp.Value);
                if (bDisabled && kvp.Value == true)
                {
                    bDisabled = false;
                }
            }
            btnOK.Enabled = !bDisabled;

            SortSystemByNameCamparer systemCompare = new SortSystemByNameCamparer();

            allElementItems.Sort(systemCompare);
        }
        private static void invokeCommand(Document doc, PressureLossReportHelper helper, bool bForAllSystems)
        {
            //upgrade the formats
            ReportFormatUpgrades.Instance.executeUpgrades();

            //post warning if some systems' calculation is not ALL
            ElementSet selSystems = new ElementSet();

            if (!bForAllSystems && helper.getSelectedSystems(selSystems))
            {
                WholeReportSettingsDlg settingsDlg = new WholeReportSettingsDlg();
                settingsDlg.ShowDialog();
            }
            else //post system filter
            {
                ReportSystemSelectorDlg rssDlg = new ReportSystemSelectorDlg();
                if (rssDlg.ShowDialog() == DialogResult.OK)
                {
                    UserPressureLossReportApplication.beginCommand(PressureLossReportHelper.instance.Doc, rssDlg.CheckedElements);
                }
            }
        }
        public MEPSystemInfo(MEPSystem systemElem)
        {
            system = systemElem;
            if (system == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            MEPSystemType sysType = helper.Doc.GetElement(system.GetTypeId()) as MEPSystemType;

            if (sysType != null)
            {
                helper.SystemClassification = sysType.SystemClassification;
            }
        }
        private void getFields(List <string> fileds)
        {
            if (fileds == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            if (helper.ReportData.AvailableFields != null)
            {
                helper.getFieldsFromReportdata(helper.ReportData.AvailableFields, fileds);
            }

            fileds.Insert(0, ReportResource.elementFiled);
            fileds.Add(ReportResource.totalPressureLoss);
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || sections == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            writer.addTitleRow(ReportResource.sectionTitle);


            //section title
            List <string> strSectionFields = new List <string>();

            getFields(strSectionFields);
            DataTable tbTitle = new DataTable();

            helper.getTableTitle(tbTitle, strSectionFields, false, true);
            writer.AddData(tbTitle, 1);

            //each section
            foreach (MEPSection section in sections)
            {
                DataTable tb = new DataTable();
                if (getSectionInfo(section, tb))
                {
                    writer.AddData(tb, 1);
                }
            }
        }