''' simple_ribbon.py - creates a ribbon panel with a single push button. NOTE: - this MUST be set as a startup script for it to work - the RPS variable "EXAMPLES_PATH" must be set and contain "helloworld.py" ''' # script that is run when Revit starts in the IExternalApplication.Startup event. try: import os import clr clr.AddReference('PresentationCore') from System.Windows.Media.Imaging import BitmapImage from System import Uri from RevitPythonShell.RpsRuntime import ExternalCommandAssemblyBuilder from Autodesk.Revit.UI import * SCRIPT_PATH = r"d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples01\opensec.py" SCRIPT_PATH_2 = r"d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples01\opensec.2.py" LARGE_IMG_PATH = r"d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples01\resource\tb2.png" LARGE_IMG_PATH2 = r"d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples01\resource\bone.png" SMALL_IMG_PATH = r"d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples01\PythonScript16x16.png" #EXAMPLES_PATH = __vars__["d:\Users\Dotan\Desktop\revitpythonshell-master\RevitPythonShell\Examples"] DLL_PATH = r"C:\Users\Dotan\AppData\Roaming\RevitPythonShell2019\simple_ribbon.dll" builder = ExternalCommandAssemblyBuilder() builder.BuildExternalCommandAssembly( DLL_PATH, {'opensec': SCRIPT_PATH}) #exmple02 tabName = "dotTab" tab = __uiControlledApplication__.CreateRibbonTab(tabName) panel = __uiControlledApplication__.CreateRibbonPanel(tabName, "New ribb") button1 = PushButtonData("opensec", "My Button #1", DLL_PATH, 'opensec') button1.ToolTip = "Say Hello world" contextHelp = ContextualHelp(ContextualHelpType.Url, "http://www.autodesk.com") button1.SetContextualHelp(contextHelp) button1.LargeImage = BitmapImage(Uri(LARGE_IMG_PATH)) builder2 = ExternalCommandAssemblyBuilder() builder2.BuildExternalCommandAssembly( DLL_PATH, {'opensec.2': SCRIPT_PATH_2}) button2 = PushButtonData("opensec2", "My Button #2", DLL_PATH, 'opensec.2') button2.ToolTip = "Say Hello " contextHelp = ContextualHelp(ContextualHelpType.Url, "http://www.autodesk.com") button2.SetContextualHelp(contextHelp) button2.LargeImage = BitmapImage(Uri(LARGE_IMG_PATH2)) panel.AddItem(button1) panel.AddItem(button2) except: import traceback # note: add a python27 library to your search path first! traceback.print_exc() # helps you debug when things go wrong