Exemple #1
0
        /// <summary>
        /// Based on mode, it reset the Revit property, or return the selected one from shown popup
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="revitFamily"></param>
        /// <param name="currentRefParam"></param>
        /// <param name="RevitUsedParams"></param>
        /// <returns></returns>
        private string GetRevitFamilyParameter(RevitFamilyHandling mode, string revitFamily, string currentRefParam, IList <string> RevitUsedParams)
        {
            NLogger.LogText("Entered GetRevitFamilyParameter");

            string revitFamilyParam = "";

            switch (mode)
            {
            case RevitFamilyHandling.ResetRevitFamily:
                revitFamilyParam = "";
                break;

            case RevitFamilyHandling.SetRevitFamily:

                var revitFamiliesParamsSelectionPopup = new RevitFamiliesParametersSelectionPopup(revitFamily, runtimeElStructureList, RevitUsedParams);
                var result = revitFamiliesParamsSelectionPopup.ShowDialog();

                //  Update Mapping grids with data coming from popup or leave the original value if click on Cancel button
                if (result == DialogResult.OK)
                {
                    //  Update RevitInventorParameters mapping datagrid with Revit family Parameter selected in the popup
                    revitFamilyParam = revitFamiliesParamsSelectionPopup.SelectedRevitFamilyParam;
                }
                else
                {
                    revitFamilyParam = currentRefParam;
                }
                break;
            }

            NLogger.LogText("Exit GetRevitFamilyParameter");

            return(revitFamilyParam);
        }
Exemple #2
0
        private string GetRevitFamily(RevitFamilyHandling mode)
        {
            string revitFamily = "";

            switch (mode)
            {
            case RevitFamilyHandling.ResetRevitFamily:
                revitFamily = "null";
                break;

            case RevitFamilyHandling.SetRevitFamily:

                //  Open Revit families popup
                var revitFamiliesSelectionPopup = new RevitFamiliesSelectionPopup(runtimeElStructureList);
                var result = revitFamiliesSelectionPopup.ShowDialog();

                //  Update Mapping grids with data coming from popup
                if (result == DialogResult.OK)
                {
                    //  Update RevitInventor mapping datagrid with Revit family selected in the popup
                    revitFamily = revitFamiliesSelectionPopup.SelectedRevitFamily;
                }
                break;
            }

            return(revitFamily);
        }
Exemple #3
0
        //  Handles the UI logic of the row selected + button click on the InventorRevit mapping grid
        private void HandleRowSelection(RevitFamilyHandling mode)
        {
            NLogger.LogText("Entered HandleRowSelection");

            var    invTemplRowCount    = dgInvRevMapping.Rows.GetRowCount(DataGridViewElementStates.Selected);
            string invTemplateFileName = "";
            int    selectedRow         = -1;

            if (invTemplRowCount == 1)
            {
                invTemplateFileName = dgInvRevMapping.SelectedRows[0].Cells["Inventor Template"].Value.ToString();
                selectedRow         = dgInvRevMapping.SelectedRows[0].Index;
            }
            else
            {
                //MessageBox.Show("You have to select one Inventor Template");
                MessageBox.Show(LanguageHandler.GetString("msgBox_SelInvTemplate"));

                return;
            }

            //  If zip file, cannot associate parameters
            var isZipFile = System.IO.Path.GetExtension(invTemplateFileName) == ".zip";

            if (isZipFile)
            {
                //MessageBox.Show("Cannot map parameters for zip file");
                MessageBox.Show(LanguageHandler.GetString("msgBox_ZipFileParamMap"));
                return;
            }

            //  Set or reset Revit Family
            var selRevFamily = GetRevitFamily(mode);

            NLogger.LogText($"Selected Revit Family {selRevFamily}");

            if (string.IsNullOrEmpty(selRevFamily))
            {
                return;
            }

            var dataSource = offsitePanelHandler.RefreshInvRevitMappingDataGridSource(selRevFamily, invTemplateFileName);

            var elementList = dataSource["InvRevMapping"];

            NLogger.LogText("Fill InventorRevitMapping grid");
            offsitePanelHandler.FillGrid(dgInvRevMapping, elementList);

            NLogger.LogText("Set selected rows on  InventorRevitMapping and ParametersMapping grids");
            dgInvRevMapping.ClearSelection();
            dgInvRevMapping.CurrentCell                = dgInvRevMapping.Rows[selectedRow].Cells["Inventor Template"];
            dgInvRevMapping.CurrentRow.Selected        = false;
            dgInvRevMapping.Rows[selectedRow].Selected = true;

            dgParamsMapping.ClearSelection();
            dgParamsMapping.Rows[0].Selected = true;

            NLogger.LogText("Exit HandleRowSelection");
        }
Exemple #4
0
        private void HandleRowSelectionParams(RevitFamilyHandling mode)
        {
            NLogger.LogText("Entered HandleRowSelectionParams");

            //  Force selection of an Inventor - Revit association
            var    invRevMapRowCount = dgInvRevMapping.Rows.GetRowCount(DataGridViewElementStates.Selected);
            string revitFileName     = "";
            string revitFamily       = "";
            string inventorTemplate  = "";
            int    selectedRow       = -1;

            //  check if a row is selected in Inventor - revit mapping and if a family is associated
            if (invRevMapRowCount == 1)
            {
                revitFamily      = dgInvRevMapping.SelectedRows[0].Cells["Revit Family"].Value?.ToString();
                inventorTemplate = dgInvRevMapping.SelectedRows[0].Cells["Inventor Template"].Value?.ToString();

                if (!string.IsNullOrEmpty(revitFamily) && !(revitFamily == "null"))
                {
                    revitFileName = Utility.GetStringForFolderName(revitFamily);
                }
                else
                {
                    //MessageBox.Show("There must be a Revit Family associated with the selected inventor template");
                    MessageBox.Show(LanguageHandler.GetString("msgBox_RevitFamAssociat"));

                    return;
                }
            }
            else
            {
                //MessageBox.Show("You have to select one Inventor - Revit mapping row");
                MessageBox.Show(LanguageHandler.GetString("msgBox_SelInvRevMapRow"));

                return;
            }

            //  Force selection of a parameters
            var    invRevParamRowCount = dgParamsMapping.Rows.GetRowCount(DataGridViewElementStates.Selected);
            string selInvParam         = "";
            string currentRevitParam   = "";

            if (invRevParamRowCount == 1)
            {
                selInvParam       = dgParamsMapping.SelectedRows[0].Cells["Inventor Key Parameters"].Value.ToString();
                currentRevitParam = dgParamsMapping.SelectedRows[0].Cells["Revit Parameters"].Value.ToString();
                selectedRow       = dgParamsMapping.SelectedRows[0].Index;
            }
            else
            {
                //MessageBox.Show("You have to select one Parameter mapping row");
                MessageBox.Show(LanguageHandler.GetString("msgBox_SelParamMapRow"));

                return;
            }

            //  Read Revit Family Param from popup or reset it, checking if the Revit parameter is already assigned
            var RevitUsedParams = offsitePanelHandler.GetRevitFamilyParamsAlreadyUsed(revitFamily);

            var selRevFamilyParam = GetRevitFamilyParameter(mode, revitFamily, currentRevitParam, RevitUsedParams);

            var dataSource = offsitePanelHandler.RefreshInvRevitParamsMappingDataGridSource(revitFamily, inventorTemplate, selInvParam, selRevFamilyParam);

            //  Fill grid
            var elementList = dataSource["ParamsMapping"];

            offsitePanelHandler.FillGrid(dgParamsMapping, elementList);

            //  Update counter of mapped parameters
            var mappedParams = elementList.Where(l => !string.IsNullOrEmpty(l.RevitParamName)).Count();

            lblNumbOfMappedParams.Text = mappedParams.ToString();

            //  Set selected row:
            //  the row is changes if a real parameter mapping has been done and if the end of the grid has not been reached
            if (selectedRow < (dgParamsMapping.Rows.Count - 1) &&
                mode == RevitFamilyHandling.SetRevitFamily &&
                !(selRevFamilyParam == currentRevitParam)
                )
            {
                selectedRow = selectedRow + 1;

                UpdateRowSelection(selectedRow);
            }
            else
            {
                UpdateRowSelection(selectedRow);
            }

            NLogger.LogText("Exit HandleRowSelectionParams");
        }