Code: Select all
During initialization the error "name 'Toggle1_1' is not defined" occurred in C:\Current FreeCAD\FreeCAD_weekly-builds-24910-Win-Conda_vc14.x-x86_64\Mod\MacroStartup\InitGui.py
I have my macro "Toggle1_1.py" in the MacroStartup folder and the added "run()" statement is in it, just like what the directions said. Here is a listing of the InitGui but It's not very clear in the instructions what should be put in the "Important" section at the bottom, this is what I did:
Code: Select all
def runMacroStartup(name):
#Do not run when NoneWorkbench is activated because UI isn't yet completely there
if name != "NoneWorkbench":
#Run macro only once by disconnecting the signal at first call
FreeCADGui.getMainWindow().workbenchActivated.disconnect(runMacroStartup)
##Following 2 lines shall be duplicated for each macro to run
import Toggle1_1
Toggle1_1.run()
##The following 2 lines are important because InitGui.py files are passed to the exec() function...
##...and the runMacro wouldn't be visible outside. So explicitly add it to __main__
import __main__
__main__.runMacro = Toggle1_1
##Connect the function that runs the macro to the appropriate signal
FreeCADGui.getMainWindow().workbenchActivated.connect(Toggle1_1)
Thanks