Python FreeCADGui.addCommand() Examples

The following are 10 code examples of FreeCADGui.addCommand(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module FreeCADGui , or try the search function .
Example #1
Source File: gui.py    From FreeCAD_assembly3 with GNU General Public License v3.0 6 votes vote down vote up
def register(mcs,cls):
        if cls._id < 0:
            return
        super(AsmCmdManager,mcs).register(cls)
        FreeCADGui.addCommand(cls.getName(),cls)
        if cls._toolbarName:
            tb = mcs.Toolbars.setdefault(cls._toolbarName,[])
            if not tb and not getattr(cls,'_toolbarVisible',True):
                mcs._HiddenToolbars.add(cls._toolbarName)
            tb.append(cls)

        if cls._menuGroupName is not None:
            name = cls._menuGroupName
            if not name:
                name = mcs._defaultMenuGroupName
            mcs.Menus.setdefault(name,[]).append(cls) 
Example #2
Source File: CommandsEagle.py    From flamingo with GNU Lesser General Public License v3.0 6 votes vote down vote up
def addCommand(name,cmdObject):
	(list,num) = inspect.getsourcelines(cmdObject.Activated)
	pos = 0
	# check for indentation
	while(list[1][pos] == ' ' or list[1][pos] == '\t'):
		pos += 1
	source = ""
	for i in range(len(list)-1):
		source += list[i+1][pos:]
	FreeCADGui.addCommand(name,cmdObject,source)

#---------------------------------------------------------------------------
# The command classes
#---------------------------------------------------------------------------

# Eagle import tool
# Riccardo Treu - LGPL  2016 
Example #3
Source File: FastenerBase.py    From FreeCAD_FastenersWB with GNU General Public License v2.0 6 votes vote down vote up
def getCommands(self, group):      
    cmdlist = []
    cmdsubs = {}
    for cmd in self.commands[group]:
      command, subgroup = cmd
      if subgroup != None and GroupButtonMode > 0:
        if not(subgroup in cmdsubs):
          cmdsubs[subgroup] = []
          if GroupButtonMode == 2:
            cmdlist.append(subgroup.replace(" ", ""))
            cmdlist.append("Separator")
        cmdsubs[subgroup].append(command)     
      else:
        cmdlist.append(command)
    for subcommand in cmdsubs:
      if GroupButtonMode == 2:
        Gui.addCommand(subcommand.replace(" ", ""), FSGroupCommand(cmdsubs[subcommand], subcommand, subcommand))
      else:
        cmdlist.append((subcommand.replace(" ", ""), cmdsubs[subcommand], subcommand))
    return cmdlist 
Example #4
Source File: init_gui.py    From freecad.gears with GNU General Public License v3.0 5 votes vote down vote up
def Initialize(self):
        from .commands import CreateCycloideGear, CreateInvoluteGear
        from .commands import CreateBevelGear, CreateInvoluteRack, CreateCrownGear
        from .commands import CreateWormGear
        self.appendToolbar("Gear", self.commands)
        self.appendMenu("Gear", self.commands)
        # Gui.addIconPath(App.getHomePath()+"Mod/gear/icons/")
        Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear())
        Gui.addCommand('CreateCycloideGear', CreateCycloideGear())
        Gui.addCommand('CreateBevelGear', CreateBevelGear())
        Gui.addCommand('CreateInvoluteRack', CreateInvoluteRack())
        Gui.addCommand('CreateCrownGear', CreateCrownGear())
        Gui.addCommand('CreateWormGear', CreateWormGear()) 
Example #5
Source File: CommandsPipe.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def addCommand(name,cmdObject):
	(list,num) = inspect.getsourcelines(cmdObject.Activated)
	pos = 0
	# check for indentation
	while(list[1][pos] == ' ' or list[1][pos] == '\t'):
		pos += 1
	source = ""
	for i in range(len(list)-1):
		source += list[i+1][pos:]
	FreeCADGui.addCommand(name,cmdObject,source)

#---------------------------------------------------------------------------
# The command classes
#--------------------------------------------------------------------------- 
Example #6
Source File: CommandsSpSh.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def addCommand(name,cmdObject):
	(list,num) = inspect.getsourcelines(cmdObject.Activated)
	pos = 0
	# check for indentation
	while(list[1][pos] == ' ' or list[1][pos] == '\t'):
		pos += 1
	source = ""
	for i in range(len(list)-1):
		source += list[i+1][pos:]
	FreeCADGui.addCommand(name,cmdObject,source)

#---------------------------------------------------------------------------
# The command classes
#--------------------------------------------------------------------------- 
Example #7
Source File: CommandsFrame.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def addCommand(name,cmdObject):
	(list,num) = inspect.getsourcelines(cmdObject.Activated)
	pos = 0
	# check for indentation
	while(list[1][pos] == ' ' or list[1][pos] == '\t'):
		pos += 1
	source = ""
	for i in range(len(list)-1):
		source += list[i+1][pos:]
	FreeCADGui.addCommand(name,cmdObject,source)

#---------------------------------------------------------------------------
# The command classes
#--------------------------------------------------------------------------- 
Example #8
Source File: CommandsPolar.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def addCommand(name,cmdObject):
	(list,num) = inspect.getsourcelines(cmdObject.Activated)
	pos = 0
	# check for indentation
	while(list[1][pos] == ' ' or list[1][pos] == '\t'):
		pos += 1
	source = ""
	for i in range(len(list)-1):
		source += list[i+1][pos:]
	FreeCADGui.addCommand(name,cmdObject,source)

#---------------------------------------------------------------------------
# The command classes
#--------------------------------------------------------------------------- 
Example #9
Source File: InitGui.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def c1a(menu,isactive,name,*info):
	global _Command
	name1="Animation_"+name
	t=_Command(name,*info)
	t.IsActive=isactive
	FreeCADGui.addCommand(name1,t)
	FreeCAD.tcmds6.append([menu,name1,name,isactive,info]) 
Example #10
Source File: InitGui.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def c2a(menu,isactive,title,name,*info):
	global _Command
	t=_Command(name,*info)
	title1="Animation_"+title
	t.IsActive=isactive
	FreeCADGui.addCommand(title1,t)
	FreeCAD.tcmds6.append([menu,title1,name,isactive,info])


# special conditions for actions