예제 #1
0
        public void ExecuteLoadProcess(List <string> files, List <string> families)
        {
            Docs docs = new Docs(App);
            int  i    = 0;

            //Through each file iterating
            foreach (string file in files)
            {
                i++;
                docs.OpenDoc(file, out Document doc);

                //Logs write
                LoadReport.Add(i + ". File path: " + doc.PathName + "\n");

                TransactionCommit(doc, families);
            }


            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName       = CurDateTime + "_Log.txt",
                DS_LogOutputPath = DialogForms.SourcePath + "\\" + "Log" + "\\"
            };

            WriteLogToFile(dS_Tools);

            TaskDialog.Show("Revit", "Process completed successfully!");

            MyApplication.thisApp.m_MyForm.Close();
        }
예제 #2
0
        void WriteLogToFile(DS_Tools dS_Tools)
        {
            dS_Tools.DS_StreamWriter("Path to shared parameters file: " + "\n" + StartForm.SPFPath + "\n");
            dS_Tools.DS_StreamWriter("Path to shared parameters file: " + "\n" + StartForm.FileWithProjectsPathes + "\n");
            dS_Tools.DS_StreamWriter("Group: " + SelectParameters.SelectedGroupName + "\n");
            dS_Tools.DS_StreamWriter("Selected parameters: " + "\n" + dS_Tools.DS_ListToString(StartForm.SelectesParameters) + "\n");
            dS_Tools.DS_StreamWriter("Files updated: " + "\n" + dS_Tools.DS_ListToString(FilesUpdated) + "\n");

            dS_Tools.DS_FileExistMessage();
        }
예제 #3
0
        public void Program(UIApplication uiapp)
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName = CurDateTime + "_Log.txt"
            };

            GetAllModelElements(uiapp, dS_Tools);

            dS_Tools.DS_FileExistMessage();
        }
예제 #4
0
        void GetFiles(UIApplication uiapp, string dir, DS_Tools dS_Tools)
        {
            //Get files list from current directory
            string        ext = "rvt";
            List <string> FileFullNames_Filtered = FileFilter(dir, ext);

            foreach (string FileName in FileFullNames_Filtered)
            {
                string NWCFileName = Path.GetFileNameWithoutExtension(FileName);
                NWC_Export(uiapp, FileName, NWCFileName);
            }
        }
예제 #5
0
        void WriteLogToFile(DS_Tools dS_Tools)
        {
            dS_Tools.DS_StreamWriter("Directory for checking '*.rvt' files: " + "\n" + DialogForms.SourcePath + "\n");
            dS_Tools.DS_StreamWriter("Directory for families '*.rfa' files: " + "\n" + DialogForms.FamilyPath + "\n");

            //Saved file names with empty models
            if (LoadReport.Count != 0)
            {
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(LoadReport));
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #6
0
        void WriteLogToFile(DS_Tools dS_Tools)
        {
            dS_Tools.DS_StreamWriter("Path to shared parameters file: " + "\n" + EntryCommand.SPFPath + "\n");
            dS_Tools.DS_StreamWriter("Group: " + selectedGroupName + "\n");
            dS_Tools.DS_StreamWriter("Added parameters:");

            //Saved file names with empty models
            if (ParametersAdded.Count != 0)
            {
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(ParametersAdded));
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #7
0
        void LogOutput(DS_Tools dS_Tools)
        {
            dS_Tools.DS_StreamWriter("Directory for checking '*.rvt' files: " + "\n" + SourcePath + "\n");
            dS_Tools.DS_StreamWriter("Directory for output '*.nwc' files: " + "\n" + DestinationPath + "\n");

            if (FileSize != 0)
            {
                dS_Tools.DS_StreamWriter("File size: " + FileSize / 1000000 + " MB" + "\n");
            }
            if (FileDate != 0)
            {
                dS_Tools.DS_StreamWriter("File date: " + FileDate + " days" + "\n");
            }

            //Saved file names with pathes write to log
            if (FileFiltered.Count != 0)
            {
                dS_Tools.DS_StreamWriter("NWC files have been created: ");
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(FileFiltered));
                MessageBox.Show("Process has been completed successfully!");
            }
            else
            {
                dS_Tools.DS_StreamWriter("No NWC files have been created.");
                MessageBox.Show("Process has been completed with errors. \n See log file.");
            }

            //Saved file names with empty models
            if (EmptyModels.Count != 0)
            {
                dS_Tools.DS_StreamWriter("\n Files with no geometry have been found: ");
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(EmptyModels));
            }

            //Saved file names with empty models
            if (NewDirNWClist.Count != 0)
            {
                dS_Tools.DS_StreamWriter("\n New directories have been created: ");
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(NewDirNWClist));
            }

            //Saved file names with empty models
            if (LinkedDocs.Count != 0)
            {
                dS_Tools.DS_StreamWriter("\n Export error with next linked documents: ");
                dS_Tools.DS_StreamWriter(dS_Tools.DS_ListToString(LinkedDocs));
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #8
0
        void LogOutput()
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogOutputPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop\Logs\"),
                DS_LogName       = CurDateTime + "_Log.txt"
            };

            dS_Tools.DS_StreamWriter("Lines coordinates start and end: \n");

            //Lines coordinates output
            int i;

            for (i = 0; i < Line_XY.Count; i++)
            {
                dS_Tools.DS_StreamWriter($"#{i + 1}: " +
                                         $"({Line_XY[i].X1}; {Line_XY[i].Y1}), ({Line_XY[i].X2}; {Line_XY[i].Y2})");
            }

            //Intersections output
            dS_Tools.DS_StreamWriter("\nIntersections coordinates:\n");
            i = 0;
            foreach (Point3d interPoint in IntersectionsList)
            {
                //Transform float to string with double precision
                string XaOut  = String.Format("{0:0.00}", interPoint.X);
                string YaOut  = String.Format("{0:0.00}", interPoint.Y);
                string Output = $"({XaOut}; {YaOut})";

                i++;
                dS_Tools.DS_StreamWriter($"#{i}: {Output}");
            }

            //Final lines coordinates output
            dS_Tools.DS_StreamWriter("\nChanged lines coordinates start and end: \n");
            for (i = 0; i < FinalLines_XY.Count; i++)
            {
                //Transform float to string with double precision
                string X1     = String.Format("{0:0.00}", FinalLines_XY[i].X1);
                string X2     = String.Format("{0:0.00}", FinalLines_XY[i].Y1);
                string Y1     = String.Format("{0:0.00}", FinalLines_XY[i].X2);
                string Y2     = String.Format("{0:0.00}", FinalLines_XY[i].Y2);
                string Output = $"#{i + 1}: ({X1}; {Y1}), ({X2}; {Y2})";

                dS_Tools.DS_StreamWriter(Output);
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #9
0
 public void DirIterate(UIApplication uiapp, string CheckedPath, DS_Tools dS_Tools)
 //Output files names list and it's direcories to Log
 {
     try
     {
         //Check folders
         foreach (string dir in Directory.GetDirectories(CheckedPath))
         {
             GetFiles(uiapp, dir, dS_Tools);
             DirIterate(uiapp, dir, dS_Tools);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #10
0
        public void OutputExistingLayerList(List <string> ExistLayers, string Source)
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogOutputPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop\Logs\"),
                DS_LogName       = CurDateTime + "_Log.txt"
            };

            dS_Tools.DS_StreamWriter($"This layers alredy exist in {Source}: \n");

            foreach (string ln in ExistLayers)
            {
                dS_Tools.DS_StreamWriter(ln);
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #11
0
        public void IterateThroughtFiles()
        {
            int i = 0;

            CategorySet cats = SetCatergoty();

            try
            {
                //Through each file iterating
                foreach (string file in StartForm.FilesPathes)
                {
                    i++;
                    Document doc = App.Application.OpenDocumentFile(file);


                    //Logs write
                    FilesUpdated.Add(i + ". File path: " + doc.PathName);

                    foreach (string parameter in StartForm.SelectesParameters)
                    {
                        AddParameterToProject(doc, cats, BuiltInParameterGroup.PG_DATA, parameter);
                    }

                    doc.Close(true);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }



            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName       = CurDateTime + "_Log.txt",
                DS_LogOutputPath = Path.GetDirectoryName(StartForm.SPFPath) + "\\" + "Log" + "\\"
            };

            WriteLogToFile(dS_Tools);

            TaskDialog.Show("Revit", "Process completed successfully!");

            MyApplication.thisApp.m_MyForm.Close();
        }
예제 #12
0
        public void DS_MainProgram(UIApplication uiapp)
        //Intiating main process
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName       = CurDateTime + "_Log.txt",
                DS_LogOutputPath = DestinationPath + "\\" + "Log" + "\\"
            };

            //Get all exist directories in DestinationPath
            GetDirNamesNWC();

            GetFiles(uiapp, SourcePath, dS_Tools);

            DirIterate(uiapp, SourcePath, dS_Tools);

            LogOutput(dS_Tools);
        }
예제 #13
0
        public void LoadParametersToSPF()
        {
            App.Application.SharedParametersFilename = EntryCommand.SPFPath;
            DefinitionGroup defG = App.Application.OpenSharedParameterFile().
                                   Groups.get_Item(selectedGroupName);

            ParameterType type = (ParameterType)Enum.Parse(typeof(ParameterType), selectedTypeName, true);

            List <string> names = File.ReadAllLines(EntryCommand.ParametersNamesPath).ToList();

            //Check if parameters with this names alredy exists
            if (CheckExistDefinitions(names).Count != 0)
            {
                string delimiter    = "\n";
                string StringOutput = CheckExistDefinitions(names).Aggregate((i, j) => i + delimiter + j);
                MessageBox.Show("Error occured! Parameters alredy exists: \n" + StringOutput);
                return;
            }

            try
            {
                foreach (string name in names)
                {
                    //Add curent parameter name
                    AddParameterToSPF(defG, name, type, true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message);
            }

            //Log writer initiation
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName       = CurDateTime + "_AddParametersToSPF_Log.txt",
                DS_LogOutputPath = Path.GetDirectoryName(EntryCommand.SPFPath) + "\\" + "Log" + "\\"
            };

            MessageBox.Show("Completed successfully!");

            WriteLogToFile(dS_Tools);
        }
예제 #14
0
        void WriteToLog(ArrayList styleList)
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogName       = CurDateTime + "_StylesRename_Log.txt",
                DS_LogOutputPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop\Logs\")
            };

            dS_Tools.DS_StreamWriter("Styles updated: ");

            try
            {
                //get type list without duplicates
                List <string> typleList = new List <string>();
                foreach (StyleInfo stf in styleList)
                {
                    if (!typleList.Contains(stf.type))
                    {
                        typleList.Add(stf.type);
                    }
                }

                //Output to Log
                foreach (string type in typleList)
                {
                    dS_Tools.DS_StreamWriter("\n" + type);
                    foreach (StyleInfo st in styleList)
                    {
                        if (st.type == type)
                        {
                            dS_Tools.DS_StreamWriter(st.name.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            dS_Tools.DS_FileExistMessage();
        }
예제 #15
0
        public void GetAllModelElements(UIApplication uiapp, DS_Tools dS_Tools)
        //Get all physical elements in active document

        {
            Document doc = uiapp.ActiveUIDocument.Document;

            // Use shortcut WhereElementIsNotElementType() to find wall instances only
            FilteredElementCollector collector = new FilteredElementCollector(doc).WhereElementIsNotElementType();

            dS_Tools.DS_StreamWriter("The physical elements in the '" + doc.PathName + "' are:\n");

            foreach (Element e in collector)
            {
                if (IsPhysicalElement(e))
                {
                    string output = string.Format("Category: {0}  / Name: {1} + \n", e.Category.Name, e.Name);
                    dS_Tools.DS_StreamWriter(output);
                }
            }
        }
예제 #16
0
        public string DS_OpenOutputFolderDialogForm(string description = "Chose folder", string folderPath = "")
        {
            {
                FolderBrowserDialog fbd;

                if (folderPath != "")
                {
                    fbd = new FolderBrowserDialog
                    {
                        Description  = description,
                        SelectedPath = folderPath
                    };
                }
                else
                {
                    fbd = new FolderBrowserDialog
                    {
                        Description = description
                    };
                }


                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string sfp = fbd.SelectedPath;

                    DS_Tools dS_Tools = new DS_Tools();
                    if (dS_Tools.DS_HasWritePermissionOnDir(sfp) == true)
                    {
                        return(sfp);
                    }
                    else
                    {
                        MessageBox.Show("Error access to path!");
                        return("");
                    }
                }

                return("");
            }
        }
예제 #17
0
        void LogOutput()
        {
            DS_Tools dS_Tools = new DS_Tools
            {
                DS_LogOutputPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop\Logs\"),
                DS_LogName       = CurDateTime + "_Log.txt"
            };

            dS_Tools.DS_StreamWriter("Lines coordinates start and end: \n");

            int i;
            int number = 0;

            for (i = 0; i < X_Coords.Count - 1; i += 2)
            {
                number++;

                dS_Tools.DS_StreamWriter("Line " + number.ToString() + ": " +
                                         X_Coords[i].ToString() + "," + Y_Coords[i].ToString() + "; " +
                                         X_Coords[i + 1].ToString() + "," + Y_Coords[i + 1].ToString());
            }
            dS_Tools.DS_FileExistMessage();
        }