macros.py

Go to the documentation of this file.
00001 import os,FreeCAD,FreeCADGui
00002 
00003 macrosList = []
00004 macroPath = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath")
00005 
00006 class MacroCommand():
00007         "A template for macro commands"
00008         def __init__(self,macroname):
00009             self.macroname = macroname
00010 
00011         def GetResources(self):
00012             return {'Pixmap'  : 'Draft_Macro',
00013                     'MenuText': self.macroname,
00014                     'ToolTip': 'Executes the '+self.macroname+' macro'}
00015 
00016         def Activated(self):
00017             target = macroPath+os.sep+self.macroname+'.FCMacro'
00018             if os.path.exists(target): execfile(target)
00019 
00020             
00021 if macroPath:
00022     macros = []
00023     for f in os.listdir(macroPath):
00024         if ".FCMacro" in f:
00025             macros.append(f[:-8])
00026     for m in macros:
00027         cmd = 'Macro_'+m
00028         FreeCADGui.addCommand(cmd,MacroCommand(m))
00029         macrosList.append(cmd)
00030         
00031         
00032         

Generated on Wed Nov 23 19:00:21 2011 for FreeCAD by  doxygen 1.6.1