Beispiel #1
0
        //public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            TaskDialog.Show("Me", "Please use Add Remove Programs List from Control Panel." + Environment.NewLine + Environment.NewLine + "The name of the application is: 'cSharpPlaypen joshnewzealand'." + Environment.NewLine + Environment.NewLine + "Tip: Sort by 'Installed On' date.");
            ////Manually Remove Programs from the Add Remove Programs List

            return(Result.Succeeded);
        }
        public List <string> GetSymbols(List <string> FamilyPath, Document doc)
        {
            List <string> FamilyInstance = new List <string>();

            using (var transaction = new Transaction(doc, "Family Symbol Collecting"))
            {
                transaction.Start();
                Family       family = null;
                FamilySymbol symbol = null;
                foreach (var item in FamilyPath)
                {
                    if (!doc.LoadFamily(item, out family))
                    {
                        family = GetFamilyFromPath(item, doc);
                    }

                    if (family == null)
                    {
                        TaskDialog.Show("Error", item);
                        continue;
                    }


                    ISet <ElementId> familySymbolId = family.GetFamilySymbolIds();

                    foreach (ElementId id in familySymbolId)
                    {
                        symbol = family.Document.GetElement(id) as FamilySymbol;
                        if (symbol == null)
                        {
                            continue;
                        }
                        FamilyInstance.Add(symbol.Name.ToString() + " " + item);

                        string TempImgFolder = System.IO.Path.GetTempPath() + "FamilyBrowser\\";
                        string filename      = TempImgFolder + symbol.Name + ".bmp";

                        if (!File.Exists(filename))
                        {
                            System.Drawing.Size imgSize = new System.Drawing.Size(200, 200);
                            Bitmap        image         = symbol.GetPreviewImage(imgSize);
                            BitmapEncoder encoder       = new BmpBitmapEncoder();
                            encoder.Frames.Add(BitmapFrame.Create(Tools.ConvertBitmapToBitmapSource(image)));
                            FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write);

                            encoder.Save(file);
                            file.Close();
                        }
                    }
                }
                transaction.RollBack();
                return(FamilyInstance);
            }
        }
Beispiel #3
0
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
                                                ref string message, ElementSet elements)
        {
            //Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document      doc   = uiApp.ActiveUIDocument.Document;

            try
            {
                // Select some elements in Revit before invoking this command

                // Get the handle of current document.
                UIDocument uidoc = commandData.Application.ActiveUIDocument;

                // Get the element selection of current document.
                Selection selection = uidoc.Selection;
                ICollection <ElementId> selectedIds = uidoc.Selection.GetElementIds();

                if (0 == selectedIds.Count)
                {
                    // If no elements selected.
                    TaskDialog.Show("Revit", "You haven't selected any elements.");
                }
                else
                {
                    String info = "Ids of selected elements in the document are: ";
                    foreach (ElementId id in selectedIds)
                    {
                        using (Transaction trans = new Transaction(doc))
                        {
                            trans.Start("Lab");
                            trans.Commit();
                        }

                        Form1 form1 = new Form1(doc, id);
                        form1.Visible = true;
                        return(Result.Succeeded);
                    }

                    TaskDialog.Show("Revit", info);
                }
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Autodesk.Revit.UI.Result.Failed);
            }


            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Beispiel #4
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            IWin32Window revit_window
                = new JtWindowHandle(
                      ComponentManager.ApplicationWindow);

            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            if (doc.IsFamilyDocument)
            {
                TaskDialog.Show("Not a Revit RVT Project",
                                "This command requires an active Revit RVT file.");

                return(Result.Failed);
            }

            if (!(doc.ActiveView is ViewSheet))
            {
                TaskDialog.Show("Current View is not a Sheet",
                                "This command requires an active sheet view.");
                return(Result.Failed);
            }

            IList <ElementId> ids
                = Revision.GetAllRevisionIds(doc);

            int n = ids.Count;

            List <RevisionData> revision_data
                = new List <RevisionData>(n);

            foreach (ElementId id in ids)
            {
                Revision r = doc.GetElement(id) as Revision;

                revision_data.Add(new RevisionData(r));
            }

            DisplayRevisionData(revision_data,
                                revit_window);

            return(Result.Succeeded);
        }
Beispiel #5
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            TaskDialog aboutDialog = new TaskDialog($"Relay v.{Globals.RevitVersion}")
            {
                MainIcon        = TaskDialogIcon.TaskDialogIconInformation,
                MainInstruction =
                    @"Hi there! Relay allows you to add DYNs to your ribbon in a pretty okay way.",
                MainContent   = @"For a tutorial on getting started, go to <a href=""https://www.notion.so/parallaxteam/Relay-for-Revit-6732550b41d34bce8edc518c0d0e47b9"">Relay docs</a>",
                CommonButtons = TaskDialogCommonButtons.Ok,
                FooterText    = @"<a href=""https://icons8.com/"">Icons Courtesy of Icons8</a>"
            };

            var dialogResult = aboutDialog.Show();

            return(Result.Succeeded);
        }
Beispiel #6
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                string myStringYear = commandData.Application.Application.VersionName.ToString().Substring(commandData.Application.Application.VersionName.ToString().Length - 4);

                if (!Directory.Exists(Properties.Settings.Default.DevelopmentPathRoot)) //This needs to be 'one level up' from your current project (to allow for future projects)."
                {
                    string stringProgramDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                    string stringAppDataCompanyProductYearPath = stringProgramDataPath + "\\Autodesk\\Revit\\Macros\\" + myStringYear + "\\Revit\\AppHookup";

                    Properties.Settings.Default.DevelopmentPathRoot = stringAppDataCompanyProductYearPath;
                    Properties.Settings.Default.Save();
                }

                VistaFolderBrowserDialog dlg = new VistaFolderBrowserDialog();
                dlg.SelectedPath        = (Directory.Exists(Properties.Settings.Default.DevelopmentPathRoot) ? Properties.Settings.Default.DevelopmentPathRoot : "");
                dlg.ShowNewFolderButton = true;
                dlg.Description         = "Navigate to local respository folder 'Revit-API-Playpen-CSharp', choose directory called 'Source', click 'Select Folder' button.";

                if (dlg.ShowDialog() == true)
                {
                    if (System.IO.Directory.Exists(dlg.SelectedPath))
                    {
                        Properties.Settings.Default.DevelopmentPathRoot = dlg.SelectedPath;
                        Properties.Settings.Default.Save();

                        //  Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand", true).SetValue("DEVELOPDIR", dlg.SelectedPath);

                        TaskDialog.Show("Done", "Path has been set to: " + Environment.NewLine + Properties.Settings.Default.DevelopmentPathRoot);
                    }
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Catch", "Failed due to: " + ex.Message);
            }
            finally
            {
            }
            #endregion

            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                string myStringYear = commandData.Application.Application.VersionName.ToString().Substring(commandData.Application.Application.VersionName.ToString().Length - 4);

                if (!Directory.Exists(Properties.Settings.Default.DevelopmentPathRoot)) //This needs to be 'one level up' from your current project (to allow for future projects)."
                {
                    string stringProgramDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                    string stringAppDataCompanyProductYearPath = stringProgramDataPath + "\\Autodesk\\Revit\\Macros\\" + myStringYear + "\\Revit\\AppHookup";

                    Properties.Settings.Default.DevelopmentPathRoot = stringAppDataCompanyProductYearPath;
                    Properties.Settings.Default.Save();
                }

                VistaFolderBrowserDialog dlg = new VistaFolderBrowserDialog();
                dlg.SelectedPath        = (Directory.Exists(Properties.Settings.Default.DevelopmentPathRoot) ? Properties.Settings.Default.DevelopmentPathRoot : "");
                dlg.ShowNewFolderButton = true;
                dlg.Description         = "Choose your development directory, this is the SOLUTIONS PARENT DIRECTORY (two levels UP from Addin & Source directories.) and select it";

                if (dlg.ShowDialog() == true)
                {
                    if (System.IO.Directory.Exists(dlg.SelectedPath))
                    {
                        Properties.Settings.Default.DevelopmentPathRoot = dlg.SelectedPath;
                        Properties.Settings.Default.Save();

                        TaskDialog.Show("Done", "Path has been set to: " + Environment.NewLine + Properties.Settings.Default.DevelopmentPathRoot);
                    }
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Catch", "Failed due to: " + ex.Message);
            }
            finally
            {
            }
            #endregion

            return(Result.Succeeded);
        }
        private List <string> GetFamilyPath(string dir)
        {
            List <string> FamiliesList = new List <string>();

            foreach (var item in Directory.GetFiles(dir))
            {
                if (item.Contains("rfa"))
                {
                    FamiliesList.Add(item);
                }
            }

            if (FamiliesList.Count == 0)
            {
                TaskDialog.Show("Families not found", "Try to select other folder");
                System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            }
            return(FamiliesList);
        }
Beispiel #9
0
        public Result OnStartup(UIControlledApplication a)
        {
            try
            {
                GetInstance = this;
                _uiApp      = a;
                //Buil all ribbon item
                BuildUI(a);

                Handler = new ColorHandler();
                ExEvent = ExternalEvent.Create(Handler);
                return(Result.Succeeded);
            }
            catch (Exception eX)
            {
                TaskDialog td = new TaskDialog("Error in Setup");
                td.ExpandedContent = eX.GetType().Name + ": " + eX.Message + Environment.NewLine + eX.StackTrace;
                td.Show();
                return(Result.Failed);
            }
        }
        public void SwitchBetweenDeveloperAndRelease(object sender, Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs e)
        {
            try
            {
                ComboBox cBox = sender as ComboBox;

                //PushButton myPushButton00 = RibbonPanelCurrent.GetItems()[1] as PushButton;
                PushButton myPushButton02 = RibbonPanelCurrent.GetItems()[2] as PushButton;
                PushButton myPushButton03 = RibbonPanelCurrent.GetItems()[3] as PushButton;

                //if (cBox.Current.Name == "Development") myPushButton00.ClassName = dllName + ".Invoke00Development";
                if (cBox.Current.Name == "Development")
                {
                    myPushButton02.ClassName = dllName + ".Invoke01Development";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton03.ClassName = dllName + ".Invoke02";
                }

                if (cBox.Current.Name == "Release")
                {
                    myPushButton02.ClassName = dllName + ".Invoke01";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton03.ClassName = dllName + ".Invoke02";
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Catch", "Failed due to: " + ex.Message);
            }
            finally
            {
            }
            #endregion
        }
Beispiel #11
0
        public void SyncWithCentral(Document doc)
        {
            // set options for accessing central model
            var transOpts = new TransactWithCentralOptions();
            //      var transCallBack = new SyncLockCallback();
            // override default behavioor of waiting to try sync if central model is locked
            //      transOpts.SetLockCallback(transCallBack);
            // set options for sync with central
            var syncOpts       = new SynchronizeWithCentralOptions();
            var relinquishOpts = new RelinquishOptions(true);

            syncOpts.SetRelinquishOptions(relinquishOpts);
            // do not autosave local model
            syncOpts.SaveLocalAfter = false;
            syncOpts.Comment        = "ќсвобождено";
            try
            {
                doc.SynchronizeWithCentral(transOpts, syncOpts);
            }
            catch (Exception ex)
            {
                TaskDialog.Show($"Sync with model {doc.Title}", ex.Message);
            }
        }
Beispiel #12
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                if (Properties.Settings.Default.AssemblyNeedLoading)
                {
                    //2 August 2019: Start, The the following lines were added in Take 10 in order prevent double loading of packages.
                    Microsoft.Win32.RegistryKey rkbase = null;
                    rkbase = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                    string stringTargetOokiiVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Default Company Name\\Revit API NuGet Example 2019 Packages").GetValue("OokiiVersion").ToString();
                    string stringTargetXceedVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Default Company Name\\Revit API NuGet Example 2019 Packages").GetValue("XceedVersion").ToString();
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetOokiiVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Default Company Name\\Revit API NuGet Example 2019").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Ookii.Dialogs.Wpf.dll"));
                    }
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetXceedVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Default Company Name\\Revit API NuGet Example 2019").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Xceed.Wpf.Toolkit.dll"));
                    }
                    //2 August 2019: End.


                    Properties.Settings.Default.AssemblyNeedLoading = false;
                    Properties.Settings.Default.Save();
                }

                string path = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Default Company Name\\Revit API NuGet Example 2019").GetValue("TARGETDIR").ToString();;

                Assembly objAssembly01  = Assembly.Load(File.ReadAllBytes(path + "\\" + dllModuleName + ".dll"));
                string   strCommandName = "ThisApplication";

                IEnumerable <Type> myIEnumerableType = GetTypesSafely(objAssembly01);
                foreach (Type objType in myIEnumerableType)
                {
                    if (objType.IsClass)
                    {
                        if (objType.Name.ToLower() == strCommandName.ToLower())
                        {
                            object   ibaseObject = Activator.CreateInstance(objType);
                            object[] arguments   = new object[] { commandData, "Button02", elements };
                            object   result      = null;

                            result = objType.InvokeMember("OpenWindowForm", BindingFlags.Default | BindingFlags.InvokeMethod, null, ibaseObject, arguments);

                            break;
                        }
                    }
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Me", ex.Message);
            }
            finally
            {
            }
            #endregion

            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                if (Properties.Settings.Default.AssemblyNeedLoading)
                {
                    //I didn't mention this in the video (it is coded in the download), that a version check of the library is required. Error messages WILL hpapen if you have a secon dplugin referring to the same library because more often than not it will be referring to a 'different version' of the same library. This versio check is really only a few more lines of code to add, but it is a trap for young players.

                    //2 August 2019: Start, The the following lines were added in Take 10 in order prevent double loading of packages.
                    Microsoft.Win32.RegistryKey rkbase = null;
                    rkbase = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                    string stringTargetOokiiVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Default Company Name\\CSharp PLAYPEN II Google 'Josh API Revit'").GetValue("OokiiVersion").ToString();
                    string stringTargetXceedVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Default Company Name\\CSharp PLAYPEN II Google 'Josh API Revit'").GetValue("XceedVersion").ToString();
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetOokiiVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Default Company Name\\CSharp PLAYPEN II Google 'Josh API Revit'").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Ookii.Dialogs.Wpf.dll"));
                    }
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetXceedVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Default Company Name\\CSharp PLAYPEN II Google 'Josh API Revit'").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Xceed.Wpf.Toolkit.dll"));
                    }
                    //2 August 2019: End.


                    Properties.Settings.Default.AssemblyNeedLoading = false;
                    Properties.Settings.Default.Save();
                }

                string path = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Default Company Name\\CSharp PLAYPEN II Google 'Josh API Revit'").GetValue("TARGETDIR").ToString();;

                Assembly objAssembly01  = Assembly.Load(File.ReadAllBytes(path + "\\" + dllModuleName + ".dll"));
                string   strCommandName = "ThisApplication";

                IEnumerable <Type> myIEnumerableType = GetTypesSafely(objAssembly01);
                foreach (Type objType in myIEnumerableType)
                {
                    if (objType.IsClass)
                    {
                        if (objType.Name.ToLower() == strCommandName.ToLower())
                        {
                            object   ibaseObject = Activator.CreateInstance(objType);
                            object[] arguments   = new object[] { commandData, "Button02", elements };
                            object   result      = null;

                            result = objType.InvokeMember("OpenWindowForm", BindingFlags.Default | BindingFlags.InvokeMethod, null, ibaseObject, arguments);

                            break;
                        }
                    }
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Me", ex.Message);
            }
            finally
            {
            }
            #endregion

            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                if (Properties.Settings.Default.AssemblyNeedLoading)
                {
                    //2 August 2019: Start, The the following lines were added in Take 10 in order prevent double loading of packages.
                    Microsoft.Win32.RegistryKey rkbase = null;
                    rkbase = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                    string stringTargetOokiiVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand").GetValue("OokiiVersion").ToString();
                    string stringTargetXceedVersion = rkbase.OpenSubKey("SOFTWARE\\Wow6432Node\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand").GetValue("XceedVersion").ToString();
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetOokiiVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Ookii.Dialogs.Wpf.dll"));
                    }
                    if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringTargetXceedVersion).Count() == 0)
                    {
                        string stringTargetDirectory = rkbase.OpenSubKey("SOFTWARE\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand").GetValue("TARGETDIR").ToString();
                        Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Xceed.Wpf.Toolkit.dll"));
                    }
                    //2 August 2019: End.
                }

                string path = Properties.Settings.Default.DevelopmentPathRoot + "";

                Assembly objAssembly01 = Assembly.Load(File.ReadAllBytes(path + "\\" + dllModuleName + "\\AddIn\\" + dllModuleName + ".dll"));

                string strCommandName = "ThisApplication";

                IEnumerable <Type> myIEnumerableType = GetTypesSafely(objAssembly01);
                foreach (Type objType in myIEnumerableType)
                {
                    if (objType.IsClass)
                    {
                        if (objType.Name.ToLower() == strCommandName.ToLower())
                        {
                            object   ibaseObject = Activator.CreateInstance(objType);
                            object[] arguments   = new object[] { commandData, "Button_01_Invoke01Development|" + path, elements };
                            object   result      = null;

                            result = objType.InvokeMember("Start", BindingFlags.Default | BindingFlags.InvokeMethod, null, ibaseObject, arguments);

                            break;
                        }
                    }
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Catch", "Failed due to: " + ex.Message);

                string pathHeader = "Please check this file (and directory) exist: " + Environment.NewLine;
                string path       = Properties.Settings.Default.DevelopmentPathRoot + "";
                ParentSupportMethods.writeDebug(pathHeader + path + "\\" + dllModuleName + "\\AddIn\\" + dllModuleName + ".dll", true);
            }
            finally
            {
            }
            #endregion
            return(Result.Succeeded);
        }
Beispiel #15
0
 /// <summary>
 /// Internal constructor that takes a title.
 /// </summary>
 /// <param name="title">The title of the dialog</param>
 internal DialogRevitTask(string title)
 {
     dialog = new RevitUi.TaskDialog(title);
 }
Beispiel #16
0
 /// <summary>
 /// Intneral constructor that takes a Revit TaskDialog object
 /// </summary>
 /// <param name="TaskDialog">A Revit TaskDialog object.</param>
 internal DialogRevitTask(RevitUi.TaskDialog TaskDialog)
 {
     dialog = TaskDialog;
 }
Beispiel #17
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

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

            //TODO hotfix
            Ookii.Dialogs.Wpf.VistaFolderBrowserDialog fbd = new VistaFolderBrowserDialog();
            if (File.Exists(Properties.Settings.Default.DefaultSettingsPath))
            {
                if (Properties.Settings.Default.RootFolder == File.ReadAllText(Properties.Settings.Default.SettingPath))
                {
                    fbd.SelectedPath = File.ReadAllText(Properties.Settings.Default.SettingPath);
                }
                else
                {
                    fbd.SelectedPath = Properties.Settings.Default.RootFolder;
                }
            }

            else
            {
                if (string.IsNullOrEmpty(Properties.Settings.Default.RootFolder))
                {
                    fbd.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                }
                else
                {
                    fbd.SelectedPath = Properties.Settings.Default.RootFolder;
                }
            }


            if (fbd.ShowDialog() == true)
            {
                if (fbd.SelectedPath.Contains("ROCHE") && app.VersionNumber != "2015")
                {
                    TaskDialog.Show("Warning", "Please select other family path.");

                    fbd.ShowDialog();
                }

                Properties.Settings.Default.RootFolder = fbd.SelectedPath;

                Properties.Settings.Default.Save();
            }
            else
            {
                return(Result.Cancelled);
            }

            FamilyPath = GetFamilyPath(fbd.SelectedPath);

            FamilyName = GetFamilyName(FamilyPath);

            Properties.Settings.Default.SymbolList = string.Empty;

            Properties.Settings.Default.Save();

            SymbolName = GetSymbols(FamilyPath, doc);

            foreach (var item in SymbolName)
            {
                Properties.Settings.Default.SymbolList += item + "\n";
            }
            return(Result.Succeeded);
        }
        public void PlaceButtonOnModifyRibbon()
        {
            try
            {
                String SystemTabId   = "Modify";
                String SystemPanelId = "modify_shr";

                adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon;

                adWin.RibbonTab   adWinSysTab   = null;
                adWin.RibbonPanel adWinSysPanel = null;

                adWin.RibbonTab   adWinApiTab   = null;
                adWin.RibbonPanel adWinApiPanel = null;
                adWin.RibbonItem  adWinApiItem  = null;

                foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs)
                {
                    // Look for the specified system tab

                    if (ribbonTab.Id == SystemTabId)
                    {
                        adWinSysTab = ribbonTab;

                        foreach (adWin.RibbonPanel ribbonPanel
                                 in ribbonTab.Panels)
                        {
                            // Look for the specified panel
                            // within the system tab

                            if (ribbonPanel.Source.Id == SystemPanelId)
                            {
                                adWinSysPanel = ribbonPanel;
                            }
                        }
                    }
                    else
                    {
                        // Look for our API tab

                        if (ribbonTab.Id == myTA.TabName)
                        {
                            adWinApiTab = ribbonTab;

                            foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels)
                            {
                                if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName)
                                {
                                    foreach (adWin.RibbonItem ribbonItem in ribbonPanel.Source.Items)
                                    {
                                        if (ribbonItem.Id == "CustomCtrl_%CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName + "%" + myTA.Button_01)
                                        {
                                            adWinApiItem = ribbonItem;
                                        }
                                    }
                                }

                                if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelTransferring)
                                {
                                    adWinApiPanel = ribbonPanel;
                                }
                            }
                        }
                    }
                }


                if (adWinSysTab != null &&
                    adWinSysPanel != null &&
                    adWinApiTab != null &&
                    adWinApiPanel != null &&
                    adWinApiItem != null)
                {
                    adWinSysTab.Panels.Add(adWinApiPanel);
                    adWinApiPanel.Source.Items.Add(adWinApiItem);
                    adWinApiTab.Panels.Remove(adWinApiPanel);
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("me", ex.Message + Environment.NewLine + ex.InnerException);
            }
            finally
            {
            }
            #endregion
        }
Beispiel #19
0
        public void SwitchBetweenDeveloperAndRelease(object sender, Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs e)
        {
            try
            {
                ComboBox cBox = sender as ComboBox;

                //PushButton myPushButton00 = RibbonPanelCurrent.GetItems()[1] as PushButton;
                PushButton  myPushButton01_Start                     = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button01_Start").First() as PushButton;
                PushButton  myPushButton02_DrawWallTypes             = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button02_DrawWallTypes").First() as PushButton;
                PushButton  myPushButton03_SetDefault                = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button03_SetDefault").First() as PushButton;
                PushButton  myPushButton04_ManualOverrideColor       = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button04_ManualOverrideColor").First() as PushButton;
                PushButton  myPushButton07_ExtensibleStorage         = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button07_ExtensibleStorage").First() as PushButton;
                SplitButton mSplitButton_OneClickBackupSystem        = RibbonPanelCurrent.GetItems().Where(x => x.Name == "OneClickBackupSystem").First() as SplitButton;
                PushButton  myPushButton15_SingleClickFamilyBackup   = mSplitButton_OneClickBackupSystem.GetItems()[0] as PushButton;
                PushButton  myPushButton1617_AddEditParameters       = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button1617_AddEditParameters").First() as PushButton;
                PushButton  myPushButton1819_UnderstandingTransforms = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button1819_UnderstandingTransforms").First() as PushButton;
                PushButton  myPushButton_02_Uninstall                = RibbonPanelCurrent.GetItems().Where(x => x.Name == "Button_02_Uninstall").First() as PushButton;


                if (cBox.Current.Name == "Development")
                {
                    myPushButton_02_Uninstall.ClassName = dllName + ".Invoke02_Uninstall";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton01_Start.ClassName = dllName + ".DevInvoke01_Start";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton02_DrawWallTypes.ClassName = dllName + ".DevInvoke02_DrawWallTypes";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton03_SetDefault.ClassName = dllName + ".DevInvoke03_SetDefault";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton04_ManualOverrideColor.ClassName = dllName + ".DevInvoke04_ManualOverrideColor";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton07_ExtensibleStorage.ClassName = dllName + ".DevInvoke07_ExtensibleStorage";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton15_SingleClickFamilyBackup.ClassName = dllName + ".DevInvoke15_SingleClickFamilyBackup";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton1617_AddEditParameters.ClassName = dllName + ".DevInvoke1617_AddEditParameters";
                }
                if (cBox.Current.Name == "Development")
                {
                    myPushButton1819_UnderstandingTransforms.ClassName = dllName + ".DevInvoke1819_UnderstandingTransforms";
                }

                if (cBox.Current.Name == "Release")
                {
                    myPushButton_02_Uninstall.ClassName = dllName + ".Invoke02_Uninstall";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton01_Start.ClassName = dllName + ".Invoke01_Start";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton02_DrawWallTypes.ClassName = dllName + ".Invoke02_DrawWallTypes";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton03_SetDefault.ClassName = dllName + ".Invoke03_SetDefault";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton04_ManualOverrideColor.ClassName = dllName + ".Invoke04_ManualOverrideColor";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton07_ExtensibleStorage.ClassName = dllName + ".Invoke07_ExtensibleStorage";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton15_SingleClickFamilyBackup.ClassName = dllName + ".Invoke15_SingleClickFamilyBackup";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton1617_AddEditParameters.ClassName = dllName + ".Invoke1617_AddEditParameters";
                }
                if (cBox.Current.Name == "Release")
                {
                    myPushButton1819_UnderstandingTransforms.ClassName = dllName + ".Invoke1819_UnderstandingTransforms";
                }


                string FILE_NAME = System.Environment.GetEnvironmentVariable("ProgramData") + "\\Pedersen Read Limited"; // cSharpPlaypen joshnewzealand

                if (true)                                                                                                //grouping for clarity will alwasy be true
                {
                    if (!System.IO.Directory.Exists(FILE_NAME))
                    {
                        System.IO.Directory.CreateDirectory(FILE_NAME);
                    }
                    FILE_NAME = FILE_NAME + "\\cSharpPlaypen joshnewzealand"; //
                    if (!System.IO.Directory.Exists(FILE_NAME))
                    {
                        System.IO.Directory.CreateDirectory(FILE_NAME);
                    }
                    FILE_NAME = (FILE_NAME + "\\Location Of Shared Parameters File.txt");
                }

                if (true) //write line
                {
                    string path = "";
                    if (cBox.Current.Name == "Release")
                    {
                        path = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Pedersen Read Limited\\cSharpPlaypen joshnewzealand").GetValue("TARGETDIR").ToString();
                    }
                    if (cBox.Current.Name == "Development")
                    {
                        string dllModuleName = "_929_Bilt2020_PlaypenChild";
                        path = Properties.Settings.Default.DevelopmentPathRoot + "\\" + dllModuleName + "\\AddIn";
                    }

                    System.IO.File.Create(FILE_NAME).Dispose();
                    System.IO.StreamWriter objWriter = new System.IO.StreamWriter(FILE_NAME, true);
                    objWriter.WriteLine(path);
                    objWriter.Close();
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("Catch", "Failed due to: " + ex.Message);
            }
            finally
            {
            }
            #endregion
        }