diff --git a/ToolCommand.py b/ToolCommand.py index db53d52..f7b3d28 100644 --- a/ToolCommand.py +++ b/ToolCommand.py @@ -22,11 +22,11 @@ class ToolCommand(): } def Activated(self): - XternalAppsParametricTool.create(self.Tool.AppName, self.Tool.ToolName) + XternalAppsParametricTool.CreateCommand(self.Tool.AppName, self.Tool.ToolName) def IsActive(self): # return false to grey out the command in the menus, toolbars etc. - return App.ActiveDocument is not None + return FreeCAD.ActiveDocument is not None def createCommands(appName): for toolName in ExternalAppsList.apps[appName].Tools: diff --git a/XternalAppsParametricTool.py b/XternalAppsParametricTool.py index 86b8d09..47e358e 100644 --- a/XternalAppsParametricTool.py +++ b/XternalAppsParametricTool.py @@ -1,15 +1,22 @@ import FreeCAD as App +import FreeCADGui #from xml.etree import ElementTree from lxml import etree import ExternalAppsList from ToolXML import * import re +def CreateCommand(appName, toolName): + App.ActiveDocument.openTransaction('Create parametric %s from %s'%(toolName, appName)) + FreeCADGui.addModule("XternalAppsParametricTool") + FreeCADGui.doCommand("XternalAppsParametricTool.create(%s, %s)"%(repr(appName), repr(toolName))) + App.ActiveDocument.commitTransaction() + return obj + def create(appName, toolName): name = appName + toolName obj = App.ActiveDocument.addObject("App::DocumentObjectGroupPython", name) XternalAppsParametricTool(obj, appName, toolName) - return obj # TODO: read-only/immutable typeToFreeCADTypeDict = {