示例#1
0
        public bool GetTitleblocks(ExternalCommandData commandData, String _selectedWallTypeName)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document  doc       = uidoc.Document;
            Selection selection = uidoc.Selection;

            //read the settings file
            cmdSettingsReadWrite cls  = new cmdSettingsReadWrite();
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");

            //open source project
            Document _openedSourceDoc = app.OpenDocumentFile(_sourceProjectPath);


            WallType _selectedWallType = null;

            //get the wall types in the source doc
            FilteredElementCollector sourceWallTypes = new FilteredElementCollector(_openedSourceDoc).OfClass(typeof(ViewSheet));

            foreach (WallType wt in sourceWallTypes)
            {
                if (wt.Name == _selectedWallTypeName)
                {
                    //the name matches
                    _selectedWallType = wt;
                }
            }



            return(true);
        }
示例#2
0
        private static string pCastFilePathFromSettings()
        {
            //Read the path from the settings file
            cmdSettingsReadWrite cls     = new cmdSettingsReadWrite();
            string returnedPCastFilePath = cls.GetSetting("<PCAST_TEMPLATE_FILE_LOCATION>");

            //return the path
            return(returnedPCastFilePath);
        }
示例#3
0
        public static string GetPathFromSettings()
        {
            //read the settings file
            cmdSettingsReadWrite cls  = new cmdSettingsReadWrite();
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");



            return(_sourceProjectPath);
        }
示例#4
0
        void GetFilePathFromSettings()
        {
            //Get the path from the settings file
            cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
            string returnedFilePath  = cls.GetSetting("<IMPORT_VIEW_FILE_PATH>");

            //Read the CSV file
            //ReadCSV(returnedDNoteFilePath);

            //Set the textbox text to the returned path for visual feedback
            tbxFilePath.Text = returnedFilePath;
        }
示例#5
0
        //search the source project for titleBlocks
        public DataTable getTitleblocks_dataTable(ExternalCommandData m_commandData)
        {
            UIApplication uiapp = m_commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document  doc       = uidoc.Document;
            Selection selection = uidoc.Selection;



            //read the settings file
            cmdSettingsReadWrite cls  = new cmdSettingsReadWrite();
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");

            //DataTable to hold the gotton catagory
            DataTable _DT_gottonCatagory = new DataTable();

            _DT_gottonCatagory = CreateEmptyDataTable("Gotton Catagory");
            DataRow dtRow;

            //var to hold the selected type
            string _userSelectedType;

            //open source project
            Document _openedSourceDoc = app.OpenDocumentFile(_sourceProjectPath);

            //Find system family to copy, e.g. using a named wall type.
            WallType _selectedWallType = null;

            //Element collector
            FilteredElementCollector sourceWallTypes = new FilteredElementCollector(_openedSourceDoc).OfClass(typeof(WallType));

            //loop thru the types and add them to the DataTable
            int _counter = 0;

            foreach (WallType wt in sourceWallTypes)
            {
                dtRow         = _DT_gottonCatagory.NewRow();
                dtRow["ID"]   = _counter;
                dtRow["Name"] = wt.Name;
                _DT_gottonCatagory.Rows.Add(dtRow);

                //increase the counter
                _counter++;
            }

            //return the DT
            return(_DT_gottonCatagory);
        }
示例#6
0
        //Button to set the path to the template file
        private void btnSetTemplatePath_Click(object sender, EventArgs e)
        {
            //Create the dialog
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //Set the initial directory
            openFileDialog1.InitialDirectory = @"C:\";

            //Set the dialog title
            openFileDialog1.Title = "Browse for pCast File";

            //Perform checks
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            //Set default extension
            openFileDialog1.DefaultExt = "txt";

            //Set the file type filter
            openFileDialog1.Filter = "pCast Files (*.txt)|*.txt";  //"Text files (*.txt)|*.txt|All files (*.*)|*.*"

            openFileDialog1.FilterIndex = 2;

            //Open to last directory
            openFileDialog1.RestoreDirectory = true;

            //Include readOnly files
            openFileDialog1.ReadOnlyChecked = true;
            openFileDialog1.ShowReadOnly    = true;

            //If the user clicks ok show the path in the textbox
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Set the text box to the returned path
                tbxTemplateFileLocation.Text = openFileDialog1.FileName;

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<PCAST_TEMPLATE_FILE_LOCATION>", openFileDialog1.FileName);

                //Call the method to reload the file path from settings and put it into the box
                tbxTemplateFileLocation.Text = pCastFilePathFromSettings();

                //reload the template list
                fillTemplateGrid(pathToTemplate);
            } //if
        }     //btnOpenFile_Click
示例#7
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            //Create the dialog
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //Set the initial directory
            openFileDialog1.InitialDirectory = @"C:\";

            //Set the dialog title
            openFileDialog1.Title = "Browse for DNote CSV File";

            //Perform checks
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            //Set default extension
            openFileDialog1.DefaultExt = "rvt";

            //Set the file type filter
            openFileDialog1.Filter = "Revit Files (*.rvt)|*.rvt";  //"Text files (*.txt)|*.txt|All files (*.*)|*.*"

            openFileDialog1.FilterIndex = 2;

            //Open to last directory
            openFileDialog1.RestoreDirectory = true;

            //Include readOnly files
            openFileDialog1.ReadOnlyChecked = true;
            openFileDialog1.ShowReadOnly    = true;

            //If the user clicks ok show the path in the textbox
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Autodesk.Revit.UI.TaskDialog.Show("Test", "OK");

                //Set the text box to the returned path
                tbxFilePath.Text = openFileDialog1.FileName;

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<IMPORT_VIEW_FILE_PATH>", openFileDialog1.FileName);

                //Call the method to reload the file path from settings and put it into the grid
                GetFilePathFromSettings();
            } //if
        }     //btnOpenFile_Click
示例#8
0
        }     //btnOpenFile_Click

        private void btnNewCSV_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.InitialDirectory = @"C:\";
            saveFileDialog1.Title            = "Save DNote File";
            saveFileDialog1.CheckFileExists  = false;
            saveFileDialog1.CheckPathExists  = true;
            saveFileDialog1.DefaultExt       = "csv";
            saveFileDialog1.Filter           = "DNote files (*.csv)|*.csv";
            saveFileDialog1.FileName         = "DNotes";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.OverwritePrompt  = true;
            saveFileDialog1.CreatePrompt     = false;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)

            {
                //Create the DNotes datatable
                DataTable dt = CreateCSVFile.CreateDNoteDataTable();

                //Get the filepath from the save dialog
                String filePath = saveFileDialog1.FileName;

                //Send the datatable to the CSV writer, this is to the writer not the reader
                dt.ToCSV(filePath);

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<DNOTE_FILE_PATH>", filePath);

                //Call the method to reload the updated file path from settings
                GetDNoteFilePathFromSettings();
            }
        }
示例#9
0
        //get and save the source project location


        public static string SourceProject(bool resetPath, string pathOrName)
        {
            cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
            string path;
            string name;

            if (resetPath == true)
            {
                //Clear the setting
                cls.UpdateSetting("<GETTER_SOURCE_PROJECT>", "");
            }

            //read the settings file
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");

            if (_sourceProjectPath != "")
            {
                name = Path.GetFileName(_sourceProjectPath);

                if (pathOrName == "Name")
                {
                    return(name);
                }
                if (pathOrName == "Path")
                {
                    return(_sourceProjectPath);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                try
                {
                    //get the file path and name
                    path = OAT_Utilities.oat_OpenFileDialog("rvt");
                    name = Path.GetFileName(path);

                    //Write the new path to the settings file
                    cls.UpdateSetting("<GETTER_SOURCE_PROJECT>", path);

                    if (pathOrName == "Name")
                    {
                        return(name);
                    }
                    if (pathOrName == "Path")
                    {
                        return(path);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
示例#10
0
        public bool GetTheTypes(ExternalCommandData commandData, String _selectedWallTypeName)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document  doc       = uidoc.Document;
            Selection selection = uidoc.Selection;

            //read the settings file
            cmdSettingsReadWrite cls  = new cmdSettingsReadWrite();
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");

            //open source project
            Document _openedSourceDoc = app.OpenDocumentFile(_sourceProjectPath);


            WallType _selectedWallType = null;

            //get the wall types in the source doc
            FilteredElementCollector sourceWallTypes = new FilteredElementCollector(_openedSourceDoc).OfClass(typeof(WallType));

            foreach (WallType wt in sourceWallTypes)
            {
                if (wt.Name == _selectedWallTypeName)
                {
                    //the name matches
                    _selectedWallType = wt;
                }
            }


            //Create a wall type in the current document

            using (Transaction tx = new Transaction(doc, "Get Types"))
            {
                tx.Start("Transfer Wall Type");

                WallType newWallType = null;

                //get the wall types in the current doc
                FilteredElementCollector wallTypes = new FilteredElementCollector(doc).OfClass(typeof(WallType));

                foreach (WallType wt in wallTypes)
                {
                    if (wt.Kind == _selectedWallType.Kind)
                    {
                        newWallType = wt.Duplicate(_selectedWallTypeName) as WallType;

                        TaskDialog.Show("Wall Created", "The selected wall has been created.");

                        break;
                    }
                }


                // Assign parameter values from source wall type:

#if COPY_INDIVIDUAL_PARAMETER_VALUE
                // Example: individually copy the "Function" parameter value:

                BuiltInParameter bip      = BuiltInParameter.FUNCTION_PARAM;
                string           function = wallType.get_Parameter(bip).AsString();
                Parameter        p        = newWallType.get_Parameter(bip);
                p.Set(function);


                BuiltInParameter bip            = BuiltInParameter.WALL_ATTR_WIDTH_PARAM;
                Double           _selectedWidth = _selectedWallType.get_Parameter(bip).AsDouble();
                Parameter        newWallWidth   = newWallType.get_Parameter(bip);
                newWallWidth.Set(_selectedWidth);
#endif // COPY_INDIVIDUAL_PARAMETER_VALUE



                Parameter p = null;

                foreach (Parameter p2 in newWallType.Parameters)
                {
                    Definition d = p2.Definition;

                    if (p2.IsReadOnly)
                    {
                        System.Diagnostics.Debug.Print(string.Format("Parameter '{0}' is read-only.", d.Name));
                    }
                    else
                    {
                        p = newWallType.get_Parameter(d);

                        if (null == p)
                        {
                            System.Diagnostics.Debug.Print(string.Format("Parameter '{0}' not found on source wall type.", d.Name));
                        }
                        else
                        {
                            if (p.StorageType == StorageType.ElementId)
                            {
                                // Here you have to find the corresponding
                                // element in the target document.

                                System.Diagnostics.Debug.Print(string.Format("Parameter '{0}' is an element id.", d.Name));
                            }
                            else
                            {
                                if (p.StorageType == StorageType.String)
                                {
                                    p2.Set(p.AsString());
                                }
                                else if (p.StorageType == StorageType.Double)
                                {
                                    p2.Set(p.AsDouble());
                                }
                                else if (p.StorageType == StorageType.Integer)
                                {
                                    p2.Set(p.AsInteger());
                                }
                                System.Diagnostics.Debug.Print(string.Format("Parameter '{0}' copied.", d.Name));
                            }
                        }
                    }
                }

                TaskDialog.Show("Parameter Set", "The walls parameters have been set.");

                MemberInfo[] memberInfos = newWallType.GetType().GetMembers(BindingFlags.GetProperty);

                foreach (MemberInfo m in memberInfos)
                {
                    // Copy the writable property values here.
                    // As there are no property writable for
                    // Walltype, I ignore this process here.
                }

                tx.Commit();
                tx.Dispose();
            }

            return(true);
        }