If I have a workbench, where should that info be placed? in initGui.py?microelly2 wrote:I had some requirements for handling macros and want remember this here
A macro should have at least theese meta information for autogenerationbackref: viewtopic.php?f=21&t=10905&start=20#p91086
Code: Select all
__Comment__ = 'Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline)' __Web__ = "http://forum.freecadweb.org/viewtopic.php?f=22&t=5554" __Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Airfoil_Import_%26_Scale" __Icon__ = "/usr/lib/freecad/Mod/plugins/icons/airfoil.png" __Help__ = "start the macro and follow the instructions" __Author__ = "quick61" __Version__ = '2.1' __Status__ = 'stable' __Requires__ = 'freecad 0.14.3706' __Communication__ = 'your email adress or yourgit or something else'
Code: Select all
class FemWorkbench(Workbench): Icon = FreeCAD.getResourceDir() + "Mod/Fem/Resources/icons/preferences-fem.svg" MenuText = "FEM Disp" ToolTip = "FEM workbench" def Initialize(self): import Fem import FemGui import subprocess from platform import system import prescribedDisplacement ccx_path = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("ccxBinaryPath") if not ccx_path: try: if system() == 'Linux': p1 = subprocess.Popen(['which', 'ccx'], stdout=subprocess.PIPE) if p1.wait() == 0: ccx_path = p1.stdout.read().split('\n') elif system() == 'Windows': ccx_path = FreeCAD.getHomePath() + 'bin/ccx.exe' FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").SetString("ccxBinaryPath", ccx_path) except Exception as e: FreeCAD.Console.PrintError(e.message) cmdList = ["Fem_NewMechanicalAnalysis", "Fem_CreateFromShape", "Fem_MechanicalMaterial", "Separator" , "Fem_CreateNodesSet" , "Separator" , "Fem_ConstraintFixed" , "Fem_PrescribedDisplacement", "Fem_ConstraintForce" , "Fem_ConstraintPressure" , "Fem_ConstraintBearing" , "Fem_ConstraintGear" , "Fem_ConstraintPulley" , "Separator" , "Fem_MechanicalJobControl" , "Fem_Quick_Analysis" , "Fem_Frequency_Analysis" , "Fem_PurgeResults" , "Fem_ShowResult"] self.appendToolbar("FEM", cmdList) self.ToolTip = "FEM workbench" self.appendMenu("FEM", cmdList) FreeCADGui.addIconPath(FreeCAD.getResourceDir() + "Mod/Fem/Resources/icons/preferences-fem.svg") def ContextMenu(self, recipient): selection = [s for s in FreeCADGui.Selection.getSelection() if s.Document == FreeCAD.ActiveDocument ] if len(selection) == 1: obj = selection if hasattr(obj,'Content'): if 'PrescribedDisplacement' in obj.Content: self.appendContextMenu("Edit Constaint", "PrescribedDispEdit") Gui.addWorkbench(FemWorkbench())
My first focus was macros, but of course for community workbenches we can and will use InitGui.py.DeepSOIC wrote:If I have a workbench, where should that info be placed? in initGui.py?microelly2 wrote:I had some requirements for handling macros and want remember this here
A macro should have at least theese meta information for autogeneration
I think that FreeCAD no longer uses pyQt and I really don't like the camel style.qingfeng.xia wrote:I am glad to see this standard.
in addition: "All public API exported to other mod should following pyQt style function name like setSomeProperty()
makeMechanicalAnalysis() is an example, if it is goning to be used somewhere else"