Example #1
0
        public AllCatCFFE2Request(UIApplication uiApp, String text)
        {
            MainUI uiForm = BARevitTools.Application.thisApp.newMainUi;

            uiForm.multiCatCFFEFamiliesProgressBar.Value = 0;
            string        saveDirectory = uiForm.multiCatCFFEFamilySaveLocation;
            DataGridView  dgv           = uiForm.multiCatCFFEFamiliesDGV;
            RVTDocument   doc           = uiApp.ActiveUIDocument.Document;
            SaveAsOptions saveAsOptions = new SaveAsOptions();

            saveAsOptions.Compact               = true;
            saveAsOptions.MaximumBackups        = 1;
            saveAsOptions.OverwriteExistingFile = true;

            //From the Comments section of the Excel template properties, get the family path for the family that was used to make the template
            string familyFileToUse = uiForm.multiCatCFFEFamilyFileToUse;

            if (!File.Exists(familyFileToUse))
            {
                //If the family does not exist at that path, prompt the user to find it
                MessageBox.Show(String.Format("Could not find the family file '{0}'. Please navigate to it in the following window", familyFileToUse));
                string file = GeneralOperations.GetFile();
                if (file != "")
                {
                    //If the family was selected, set the selection to the family to use
                    familyFileToUse = file;
                }
                else
                {
                    familyFileToUse = "";
                }
            }

            //Assuming the family file to use exists, the user has set the save location, and they have set the creation method, continue
            if (familyFileToUse != "" && uiForm.multiCatCFFEFamilySaveLocation != "" && uiForm.multiCatCFFEFamiliesDGV.Rows.Count != 0 && uiForm.multiCatCFFEFamilyCreationComboBox.Text != "<Select Creation Method>")
            {
                //Call the AllCatCFFE2Request.CreateFamilyTypesFromTable method
                CreateFamilyTypesFromTable(uiApp, uiForm, saveDirectory, dgv, saveAsOptions, familyFileToUse);
            }
            //Otherwise, tell the user
            else if (uiForm.multiCatCFFEFamilySaveLocation == "")
            {
                MessageBox.Show("No save directory selected");
            }
            else if (uiForm.multiCatCFFEFamilyCreationComboBox.Text == "<Select Creation Method>")
            {
                MessageBox.Show("Please select a creation method");
            }
            else
            {
                MessageBox.Show("No families can be made because a family to use was not identified");
            }
        }
Example #2
0
        public AdminDataGBDVRequest(UIApplication uiApp, String text)
        {
            MainUI    uiForm = BARevitTools.Application.thisApp.newMainUi;
            DataTable dt     = new DataTable();

            uiForm.adminDataGBDVWaitLabel.Text    = "Please Wait...";
            uiForm.adminDataGBDVWaitLabel.Visible = true;

            //Begin by getting the Revit version of the BA Details file in the BART properties. This should be lowest supported BART version
            string detailVersion = RVTOperations.GetRevitNumber(BARevitTools.Properties.Settings.Default.RevitProjectBADetails).ToString();
            //Get the last two digits for the year of the BA Details Revit version
            string detailSubVersion = detailVersion.Substring(detailVersion.Length - 2);
            //Get the version of Revit running and then get the last two digits
            string activeSubVersion = uiApp.Application.VersionNumber.Substring(uiApp.Application.VersionNumber.Length - 2);
            //Get the appropriate BA Details file by version number. This only works if the files are named with the A## suffix
            string detailsFile = BARevitTools.Properties.Settings.Default.RevitProjectBADetails.Replace(detailSubVersion, activeSubVersion);

            //Create a new DataTable to collect data.
            dt = new DataTable();
            DataColumn categoryColumn     = dt.Columns.Add("Category", typeof(String)); //View type
            DataColumn divisionSortColumn = dt.Columns.Add("Division", typeof(String)); //BA View Sort 1 Division
            DataColumn typeSortColumn     = dt.Columns.Add("Type", typeof(String));     //BA View Sort 2 Type
            DataColumn nameColumn         = dt.Columns.Add("Name", typeof(String));     //View name

            //Try to open the details file saved in the running version of Revit.
            RVTDocument detailsDoc = null;

            try
            {
                //Open the BA Details file
                detailsDoc = RVTOperations.OpenRevitFile(uiApp, detailsFile);
            }
            catch
            {
                //Assuming the file could not be opened because it does not exist at the expected location, prompt the user to select it.
                MessageBox.Show(String.Format("Could not load the {0} file. Please select the BA Details file to use in the following dialog.", detailsFile));
                try
                {
                    //Generate the file selection dialog
                    string filePath = GeneralOperations.GetFile();
                    detailsDoc = RVTOperations.OpenRevitFile(uiApp, filePath);
                }
                catch {; }
            }

            //Assuming the BA Details was opened, continue
            if (detailsDoc != null)
            {
                List <ViewDrafting> viewsCollection  = new FilteredElementCollector(detailsDoc).OfClass(typeof(ViewDrafting)).WhereElementIsNotElementType().Cast <ViewDrafting>().ToList();
                List <ViewSheet>    sheetsCollection = new FilteredElementCollector(detailsDoc).OfClass(typeof(ViewSheet)).WhereElementIsNotElementType().Cast <ViewSheet>().ToList();

                //Order the views by division, type, and name
                var viewsGroupedQuery =
                    from viewElem in viewsCollection
                    orderby viewElem.GetParameters("BA View Sort 1 Division").First().ToString(), viewElem.GetParameters("BA View Sort 2 Type").First().ToString(), viewElem.Name
                select viewElem;

                //Fill out the DataTable
                foreach (ViewDrafting viewDrafting in viewsGroupedQuery)
                {
                    DataRow row = dt.NewRow();
                    row["Category"] = "View";
                    row["Division"] = viewDrafting.GetParameters("BA View Sort 1 Division").First().AsString();
                    row["Type"]     = viewDrafting.GetParameters("BA View Sort 2 Type").First().AsString();
                    row["Name"]     = viewDrafting.Name;
                    dt.Rows.Add(row);
                }

                //Order the sheets by discipline, division, and name
                var sheetsGroupedQuery =
                    from sheetElem in sheetsCollection
                    orderby sheetElem.GetParameters("BA Sheet Discipline").First().AsString(), sheetElem.GetParameters("BA Sheet Division").First().AsString(), sheetElem.Name
                select sheetElem;

                //Add the sheets to the DataTable
                foreach (ViewSheet viewSheet in sheetsGroupedQuery)
                {
                    DataRow row = dt.NewRow();
                    row["Category"] = "Sheet";
                    row["Division"] = viewSheet.GetParameters("BA Sheet Discipline").First().AsString();
                    row["Type"]     = viewSheet.GetParameters("BA Sheet Division").First().AsString();
                    row["Name"]     = viewSheet.Name;
                    dt.Rows.Add(row);
                }

                uiForm.adminDataGBDVWaitLabel.Text = "Done!";
                detailsDoc.Close(false);

                uiForm.adminDataGBDVDataTable = dt;
            }
        }