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])
def createcmd2(cmd='CV',pixmap='Std_Tool1',menutext=None,tooltip=None): global makeCV_master2 try: FreeCADGui.addCommand(cmd, makeCV_master2(cmd)) cvCmds.append(cmd) except: pass
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])
def Initialize(self): """Setup""" from geometry import menger self.appendToolbar("AOER Tools", ["Menger",]) self.appendMenu("AOER Tools", ["Menger",]) FreeCADGui.addCommand('Menger', menger.MengerCommand()) Log ("Loading MyModule... done\n")
def register(self): if self.isRegistered(): import FreeCAD as App App.Console.PrintWarning(u"Re-registering command {cmd}\n".format(cmd= self.command_name)) if self.command_name is None: self.command_name = self.GetResources()['CommandName'] import FreeCADGui as Gui Gui.addCommand(self.command_name, self) global registeredCommands registeredCommands[self.command_name] = self self.is_registered = True #also register an AA version of the command if not self.AA: self.command_name_aa = self.command_name + '_AA' import copy cpy = copy.copy(self) cpy.AA = True cpy.command_name = self.command_name_aa cpy.is_registered = False #since we copied an already registered command, it thinks it's registered too. cpy.register() self.aa_command_instance = cpy return self.command_name
def c2a(menu,isactive,title,name,*info): print info global _Command t=_Command(name,*info) title1="Reconstruction_"+title t.IsActive=isactive FreeCADGui.addCommand(title1,t) FreeCAD.tcmds6.append([menu,title1])
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)
def Initialize(self): from .commands import CreateCycloideGear, CreateInvoluteGear from .commands import CreateBevelGear, CreateInvoluteRack, CreateCrownGear 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())
def Initialize(self): from gearfunc import CreateCycloideGear, CreateInvoluteGear, CreateBevelGear, CreateInvoluteRack self.appendToolbar("Gear", ["CreateInvoluteGear", "CreateInvoluteRack", "CreateCycloideGear", "CreateBevelGear"]) self.appendMenu("Gear", ["CreateInvoluteGear", "CreateInvoluteRack", "CreateCycloideGear","CreateBevelGear"]) Gui.addIconPath(App.getHomePath()+"Mod/gear/icons/") Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear()) Gui.addCommand('CreateCycloideGear', CreateCycloideGear()) Gui.addCommand('CreateBevelGear', CreateBevelGear()) Gui.addCommand('CreateInvoluteRack', CreateInvoluteRack())
def SetupOperation(name, objFactory, opPageClass, pixmap, menuText, toolTip, accelKey=None): '''SetupOperation(name, objFactory, opPageClass, pixmap, menuText, toolTip, accelKey=None) Creates an instance of CommandPathOp with the given parameters and registers the command with FreeCAD. When activated it creates a model with proxy (by invoking objFactory), assigns a view provider to it (see ViewProvider in this module) and starts the editor specifically for this operation (driven by opPageClass). This is an internal function that is automatically called by the initialisation code for each operation. It is not expected to be called manually. ''' res = CommandResources(name, objFactory, opPageClass, pixmap, menuText, accelKey, toolTip) command = CommandPathOp(res) FreeCADGui.addCommand("Path_%s" % name.replace(' ', '_'), command) return command
self.form.deleteBase.clicked.connect(self.deleteBase) self.form.reorderBase.clicked.connect(self.reorderBase) self.form.baseList.itemSelectionChanged.connect(self.itemActivated) sel = FreeCADGui.Selection.getSelectionEx() if len(sel) != 0 and sel[0].HasSubObjects: self.addBase() self.setFields() class SelObserver: def __init__(self): import PathScripts.PathSelection as PST PST.drillselect() def __del__(self): import PathScripts.PathSelection as PST PST.clear() def addSelection(self, doc, obj, sub, pnt): FreeCADGui.doCommand('Gui.Selection.addSelection(FreeCAD.ActiveDocument.' + obj + ')') FreeCADGui.updateGui() if FreeCAD.GuiUp: # register the FreeCAD command FreeCADGui.addCommand('Path_Drilling', CommandPathDrilling()) FreeCAD.Console.PrintLog("Loading PathDrilling... done\n")
class _ViewProviderWall(ArchComponent.ViewProviderComponent): "A View Provider for the Wall object" def __init__(self,vobj): ArchComponent.ViewProviderComponent.__init__(self,vobj) def getIcon(self): import Arch_rc if hasattr(self,"Object"): for o in self.Object.OutList: if Draft.getType(o) == "Wall": return ":/icons/Arch_Wall_Tree_Assembly.svg" return ":/icons/Arch_Wall_Tree.svg" def getDisplayModes(self,vobj): return ArchComponent.ViewProviderComponent.getDisplayModes(self,vobj)+["Flat 2D"] def setDisplayMode(self,mode): self.Object.Proxy.execute(self.Object) if mode == "Flat 2D": return "Flat Lines" else: return ArchComponent.ViewProviderComponent.setDisplayMode(self,mode) def attach(self,vobj): self.Object = vobj.Object return FreeCADGui.addCommand('Arch_Wall',_CommandWall()) FreeCADGui.addCommand('Arch_MergeWalls',_CommandMergeWalls())
Parameters ---------- menu: <PySide2.QtWidgets.QMenu> The context menu already assembled prior to this method being called. """ from PySide import QtCore, QtGui import Arch_rc action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_BuildingPart.svg"), "Convert to BuildingPart", menu) QtCore.QObject.connect(action1, QtCore.SIGNAL("triggered()"), self.convertToBuildingPart) menu.addAction(action1) def convertToBuildingPart(self): """Converts the floor into an Arch Building Part. TODO: May be depreciated? """ if hasattr(self, "Object"): import ArchBuildingPart from DraftGui import todo todo.delay(ArchBuildingPart.convertFloors, self.Object) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Floor', _CommandFloor())
'fem-material-fluid', 'MenuText': QtCore.QT_TRANSLATE_NOOP("FEM_MaterialFluid", "FEM material for Fluid"), 'Accel': "M, M", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("FEM_MaterialFluid", "Creates a FEM material for Fluid") } self.is_active = 'with_analysis' def Activated(self): femDoc = FemGui.getActiveAnalysis().Document if FreeCAD.ActiveDocument is not femDoc: FreeCADGui.setActiveDocument(femDoc) FreeCAD.ActiveDocument.openTransaction("Create Fluid Material") FreeCADGui.addModule("ObjectsFem") FreeCADGui.doCommand("ObjectsFem.makeMaterialFluid('FluidMaterial')") FreeCADGui.doCommand("App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member = App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member + [App.ActiveDocument.ActiveObject]") FreeCADGui.doCommand( "Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)" ) FreeCADGui.addCommand('FEM_MaterialFluid', _CommandFemMaterialFluid())
self.field2.setVisible(False) self.field3.setVisible(False) self.field4.setVisible(False) self.field5.setVisible(False) self.createButton.setVisible(False) self.addButton.setEnabled(True) def accept(self): FreeCAD.ActiveDocument.recompute() if self.obj: self.obj.ViewObject.finishEditing() return True def retranslateUi(self, TaskPanel): TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)) self.delButton.setText(QtGui.QApplication.translate("Arch", "Remove", None, QtGui.QApplication.UnicodeUTF8)) self.addButton.setText(QtGui.QApplication.translate("Arch", "Add", None, QtGui.QApplication.UnicodeUTF8)) self.editButton.setText(QtGui.QApplication.translate("Arch", "Edit", None, QtGui.QApplication.UnicodeUTF8)) self.createButton.setText(QtGui.QApplication.translate("Arch", "Create/update component", None, QtGui.QApplication.UnicodeUTF8)) self.title.setText(QtGui.QApplication.translate("Arch", "Base 2D object", None, QtGui.QApplication.UnicodeUTF8)) self.wiretree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Wires", None, QtGui.QApplication.UnicodeUTF8)]) self.comptree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)]) self.newtitle.setText(QtGui.QApplication.translate("Arch", "Create new component", None, QtGui.QApplication.UnicodeUTF8)) self.new1.setText(QtGui.QApplication.translate("Arch", "Name", None, QtGui.QApplication.UnicodeUTF8)) self.new2.setText(QtGui.QApplication.translate("Arch", "Type", None, QtGui.QApplication.UnicodeUTF8)) self.new3.setText(QtGui.QApplication.translate("Arch", "Wires", None, QtGui.QApplication.UnicodeUTF8)) self.new4.setText(QtGui.QApplication.translate("Arch", "Thickness", None, QtGui.QApplication.UnicodeUTF8)) self.new5.setText(QtGui.QApplication.translate("Arch", "Z offset", None, QtGui.QApplication.UnicodeUTF8)) FreeCADGui.addCommand('Arch_Window',_CommandWindow())
FreeCAD.Console.PrintMessage("adding vertex %s"%str(verts[-1])) if verts: return(verts) else: FreeCAD.Console.PrintMessage("\nPlease select an object that has at least 2 vertexes") return(None) def Activated(self): s = FreeCADGui.Selection.getSelectionEx() try: ordered = FreeCADGui.activeWorkbench().Selection if ordered: s = ordered except AttributeError: pass source = self.parseSel(s) if not source: return(False) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Interpolation_Curve") #add object to document Interpolate(obj,source) ViewProviderInterpolate(obj.ViewObject) FreeCAD.ActiveDocument.recompute() def GetResources(self): return {'Pixmap' : TOOL_ICON, 'MenuText': 'Interpolate', 'ToolTip': 'Interpolate points with a BSpline curve'} FreeCADGui.addCommand('Interpolate', interpolate())
modes=["Footprint"] return modes def setDisplayMode(self,mode): if mode == "Footprint": if hasattr(self,"Object"): faces = self.Object.Proxy.getFootprint(self.Object) if faces: verts = [] fdata = [] idx = 0 for face in faces: tri = face.tessellate(1) for v in tri[0]: verts.append([v.x,v.y,v.z]) for f in tri[1]: fdata.extend([f[0]+idx,f[1]+idx,f[2]+idx,-1]) idx += len(tri[0]) self.fcoords.point.setValues(verts) self.fset.coordIndex.setValues(0,len(fdata),fdata) return "Wireframe" else: self.fset.coordIndex.deleteValues(0) self.fcoords.point.deleteValues(0) return mode if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Wall',_CommandWall()) FreeCADGui.addCommand('Arch_MergeWalls',_CommandMergeWalls())
class newBody: "My tool object" def GetResources(self): return {"MenuText": "Create a new Body", "Accel": "Ctrl+B", "ToolTip": "Create a new Body in the Model", "Pixmap" : os.path.join( iconPath , 'PartDesign_Body.svg') } def IsActive(self): if App.ActiveDocument: # is something selected ? if Gui.Selection.getSelection(): return(False) else: return(True) else: return(False) def Activated(self): # do something here... bodyName = 'Body' text,ok = QtGui.QInputDialog.getText(None,'Create new Body in Model','Enter new Body name : ', text = bodyName) if ok and text: App.activeDocument().getObject('Model').newObject( 'PartDesign::Body', text ) # add the command to the workbench Gui.addCommand( 'newBodyCmd', newBody() )
def addToFreeCAD(self): FreeCADGui.addCommand(self.commandId, self)
"Base test commando object" def Activated(self): if FreeCAD.activeDocument() != None: FreeCAD.activeDocument().addObject("App::FeatureTest") else: FreeCAD.PrintMessage("No active document.\n") def GetResources(self): return { 'Pixmap': 'Std_Tool1', 'MenuText': 'Insert a TestFeauture', 'ToolTip': 'Insert a TestFeature in the active Document' } #--------------------------------------------------------------------------- # Adds the commands to the FreeCAD command manager #--------------------------------------------------------------------------- FreeCADGui.addCommand('Test_Test', TestCmd()) FreeCADGui.addCommand('Test_TestAllText', TestAllTextCmd()) FreeCADGui.addCommand('Test_TestDocText', TestDocTextCmd()) FreeCADGui.addCommand('Test_TestBaseText', TestBaseTextCmd()) FreeCADGui.addCommand('Test_TestAll', TestAllCmd()) FreeCADGui.addCommand('Test_TestDoc', TestDocCmd()) FreeCADGui.addCommand('Test_TestBase', TestBaseCmd()) FreeCADGui.addCommand('Test_TestWork', TestWorkbenchCmd()) FreeCADGui.addCommand('Test_TestCreateMenu', TestCreateMenuCmd()) FreeCADGui.addCommand('Test_TestDeleteMenu', TestDeleteMenuCmd()) FreeCADGui.addCommand('Test_InsertFeature', TestInsertFeatureCmd())
"User parameter:BaseApp/Preferences/Macro").GetString("MacroPath") class MacroCommand(): "A template for macro commands" def __init__(self, macroname): self.macroname = macroname def GetResources(self): return { 'Pixmap': 'Draft_Macro', 'MenuText': self.macroname, 'ToolTip': 'Executes the ' + self.macroname + ' macro' } def Activated(self): target = macroPath + os.sep + self.macroname + '.FCMacro' if os.path.exists(target): execfile(target) if macroPath and os.path.isdir(macroPath): macros = [] for f in os.listdir(macroPath): if ".FCMacro" in f: macros.append(f[:-8]) for m in macros: cmd = 'Macro_' + m FreeCADGui.addCommand(cmd, MacroCommand(m)) macrosList.append(cmd)
QtCore.QT_TRANSLATE_NOOP("FEM_SolverZ88", "Creates a FEM solver Z88") } self.is_active = 'with_analysis' def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create SolverZ88") FreeCADGui.addModule("ObjectsFem") FreeCADGui.doCommand( "FemGui.getActiveAnalysis().addObject(ObjectsFem.makeSolverZ88(FreeCAD.ActiveDocument))" ) FreeCAD.ActiveDocument.recompute() # the string in add command will be the page name on FreeCAD wiki FreeCADGui.addCommand('FEM_Analysis', _CommandFemAnalysis()) FreeCADGui.addCommand('FEM_ConstraintBodyHeatSource', _CommandFemConstraintBodyHeatSource()) FreeCADGui.addCommand('FEM_ConstraintElectrostaticPotential', _CommandFemConstraintElectrostaticPotential()) FreeCADGui.addCommand('FEM_ConstraintFlowVelocity', _CommandFemConstraintFlowVelocity()) FreeCADGui.addCommand('FEM_ConstraintInitialFlowVelocity', _CommandFemConstraintInitialFlowVelocity()) FreeCADGui.addCommand('FEM_ConstraintSelfWeight', _CommandFemConstraintSelfWeight()) FreeCADGui.addCommand('FEM_ElementFluid1D', _CommandFemElementFluid1D()) FreeCADGui.addCommand('FEM_ElementGeometry1D', _CommandFemElementGeometry1D()) FreeCADGui.addCommand('FEM_ElementGeometry2D', _CommandFemElementGeometry2D()) FreeCADGui.addCommand('FEM_ElementRotation1D', _CommandFemElementRotation1D()) FreeCADGui.addCommand('FEM_EquationElectrostatic',
else: pts.append(vts[i].Point.add( self.displacement)) pts = str(pts).replace("Vector ", "FreeCAD.Vector") _cmd = "Draft.makeWire" _cmd += "(" + pts + ", closed=True)" _format = "Draft.formatObject" _format += "(w, " _format += _doc + ops[0].Name _format += ")" _hide = _doc + ops[0].Name + ".ViewObject.hide()" commitops.append("w = " + _cmd) commitops.append(_format) commitops.append(_hide) else: _pl = _doc + ops[0].Name _pl += ".Placement.Base=FreeCAD." _pl += str(ops[0].Placement.Base.add( self.displacement)) commitops.append(_pl) if commitops: commitops.append("FreeCAD.ActiveDocument.recompute()") Gui.addModule("Draft") self.commit(translate("draft", "Stretch"), commitops) self.finish() Gui.addCommand('Draft_Stretch', Stretch()) ## @}
class _CommandFrequencyAnalysis: def GetResources(self): return {'Pixmap': 'fem-frequency-analysis', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Run frequency analysis with CalculiX ccx"), 'Accel': "R, F", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Write .inp file and run frequency analysis with CalculiX ccx")} def Activated(self): def load_results(ret_code): if ret_code == 0: self.fea.load_results() else: print "CalculiX failed ccx finished with error {}".format(ret_code) self.fea = FemTools() self.fea.reset_all() self.fea.set_analysis_type('frequency') message = self.fea.check_prerequisites() if message: QtGui.QMessageBox.critical(None, "Missing prerequisite", message) return self.fea.finished.connect(load_results) QtCore.QThreadPool.globalInstance().start(self.fea) def IsActive(self): return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None if FreeCAD.GuiUp: FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis())
from PyQt4 import QtCore, QtGui import FreeCAD, FreeCADGui, os # Load resources class LoadExample: def Activated(self): import VendLoad VendLoad.load() def GetResources(self): MenuText = QtCore.QT_TRANSLATE_NOOP('Ship_LoadExample', 'Load an example ship geometry') ToolTip = QtCore.QT_TRANSLATE_NOOP('Ship_LoadExample', 'Load an example ship geometry able to be converted into a ship.') return {'Pixmap' : 'LoadIco', 'MenuText': MenuText, 'ToolTip': ToolTip} FreeCADGui.addCommand('Ship_LoadExample', LoadExample())
"Part::Feature", "PreviewCutVolume") self.previewObj.ViewObject.ShapeColor = (1.00, 0.00, 0.00) self.previewObj.ViewObject.Transparency = 75 if i == 1: cutVolume = cutVolume[1] else: cutVolume = cutVolume[2] if cutVolume: self.previewObj.Shape = cutVolume def retranslateUi(self, TaskPanel): TaskPanel.setWindowTitle( QtGui.QApplication.translate("Arch", "Cut Plane", None, QtGui.QApplication.UnicodeUTF8)) self.title.setText( QtGui.QApplication.translate("Arch", "Cut Plane options", None, QtGui.QApplication.UnicodeUTF8)) self.infoText.setText( QtGui.QApplication.translate("Arch", "Wich side to cut", None, QtGui.QApplication.UnicodeUTF8)) self.combobox.addItems([ QtGui.QApplication.translate("Arch", "Behind", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Front", None, QtGui.QApplication.UnicodeUTF8) ]) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_CutPlane', _CommandCutPlane())
"called when freecad exports a csv file" import csv, Draft if not exportList: print "Spreadsheet: Nothing to export" return obj = exportList[0] if Draft.getType(obj) != "Spreadsheet": print "Spreadhseet: The selected object is not a spreadsheet" return if not obj.Proxy._cells: print "Spreadsheet: The selected spreadsheet contains no cell" return numcols = ("abcdefghijklmnopqrstuvwxyz".index(str(obj.Proxy.cols[-1])))+1 numrows = int(obj.Proxy.rows[-1]) with pyopen(filename, 'wb') as csvfile: csvfile = csv.writer(csvfile) for i in range(numrows): r = [] for j in range(numcols): key = "abcdefghijklmnopqrstuvwxyz"[j]+str(i+1) if key in obj.Proxy._cells.keys(): r.append(str(obj.Proxy.getFunction(key))) else: r.append("") csvfile.writerow(r) print "successfully exported ",filename FreeCADGui.addCommand('Spreadsheet_Create',_Command_Spreadsheet_Create()) FreeCADGui.addCommand('Spreadsheet_Controller',_Command_Spreadsheet_Controller())
return True def retranslateUi(self, TaskPanel): TaskPanel.setWindowTitle( QtGui.QApplication.translate("Arch", "Section plane settings", None)) self.delButton.setText( QtGui.QApplication.translate("Arch", "Remove", None)) self.addButton.setText( QtGui.QApplication.translate("Arch", "Add", None)) self.title.setText( QtGui.QApplication.translate( "Arch", "Objects seen by this section plane:", None)) self.rlabel.setText( QtGui.QApplication.translate("Arch", "Section plane placement:", None)) self.rotateXButton.setText( QtGui.QApplication.translate("Arch", "Rotate X", None)) self.rotateYButton.setText( QtGui.QApplication.translate("Arch", "Rotate Y", None)) self.rotateZButton.setText( QtGui.QApplication.translate("Arch", "Rotate Z", None)) self.resizeButton.setText( QtGui.QApplication.translate("Arch", "Resize", None)) self.recenterButton.setText( QtGui.QApplication.translate("Arch", "Center", None)) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_SectionPlane', _CommandSectionPlane())
return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} def IsActive(self): return FreeCAD.ActiveDocument != None def __del__(self): global WizardShaftDlg WizardShaftDlg = None class WizardShaftGuiCallback: def Activated(self): global WizardShaftDlg if WizardShaftDlg != None and WizardShaftDlg.table != None: WizardShaftDlg.table.finishEditConstraint() def isActive(self): global WizardShaftDlg return (WizardShaftDlg is not None) def GetResources(self): IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg" MenuText = 'Shaft design wizard...' ToolTip = 'Start the shaft design wizard' return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} FreeCADGui.addCommand('PartDesign_WizardShaft', WizardShaftGui()) FreeCADGui.addCommand('PartDesign_WizardShaftCallBack', WizardShaftGuiCallback()) #Note: Start wizard in Python Console with # Gui.runCommand('PartDesign_WizardShaft')
obj.Shape = sh def setOffset(self, pipe, pos, offset): if pos == "start": if pipe.OffsetStart != offset: pipe.OffsetStart = offset pipe.Proxy.execute(pipe) else: if pipe.OffsetEnd != offset: pipe.OffsetEnd = offset pipe.Proxy.execute(pipe) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Pipe', _CommandPipe()) FreeCADGui.addCommand('Arch_PipeConnector', _CommandPipeConnector()) class _ArchPipeGroupCommand: def GetCommands(self): return tuple(['Arch_Pipe', 'Arch_PipeConnector']) def GetResources(self): return { 'MenuText': QT_TRANSLATE_NOOP("Arch_PipeTools", 'Pipe tools'), 'ToolTip': QT_TRANSLATE_NOOP("Arch_PipeTools", 'Pipe tools') } def IsActive(self): return not FreeCAD.ActiveDocument is None
self.placement = False elif down == "DOWN" and self.placement is False: self.placement = True else: pass except Exception: None if self.placement is True: set_place(self.LinBearHouse, round(self.v.getPoint(pos)[0], 3), round(self.v.getPoint(pos)[1], 3), round(self.v.getPoint(pos)[2], 3)) else: pass if FreeCAD.Gui.Selection.hasSelection(): self.placement = False try: obj = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] if hasattr(obj, "Point"): # Is a Vertex pos = obj.Point else: # Is an Edge or Face pos = obj.CenterOfMass set_place(self.LinBearHouse, pos.x, pos.y, pos.z) except Exception: None # Command FreeCADGui.addCommand('LinBearHouse', _LinBearHouse_Cmd())
## @package CommandFemAnalysis # \ingroup FEM import FreeCAD from .FemCommands import FemCommands import FreeCADGui from PySide import QtCore class _CommandFemAnalysis(FemCommands): "the FEM_Analysis command definition" def __init__(self): super(_CommandFemAnalysis, self).__init__() self.resources = {'Pixmap': 'fem-analysis', 'MenuText': QtCore.QT_TRANSLATE_NOOP("FEM_Analysis", "Analysis container"), 'Accel': "N, A", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("FEM_Analysis", "Creates a analysis container with standard solver CalculiX")} self.is_active = 'with_document' def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create Analysis") FreeCADGui.addModule("FemGui") FreeCADGui.addModule("ObjectsFem") FreeCADGui.doCommand("ObjectsFem.makeAnalysis(FreeCAD.ActiveDocument, 'Analysis')") FreeCADGui.doCommand("FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.ActiveObject)") FreeCADGui.doCommand("ObjectsFem.makeSolverCalculix(FreeCAD.ActiveDocument, 'CalculiX')") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FreeCAD.ActiveDocument.ActiveObject]") FreeCADGui.addCommand('FEM_Analysis', _CommandFemAnalysis())
_menu = "Toggle On/Off" _tip = ("Activates or deactivates " "all snap tools at once") return {'Pixmap': 'Snap_Lock', 'Accel': "Shift+S", 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _menu), 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _tip)} def Activated(self): """Execute this when the command is called.""" if hasattr(FreeCADGui, "Snapper"): if hasattr(FreeCADGui.Snapper, "masterbutton"): FreeCADGui.Snapper.masterbutton.toggle() FreeCADGui.addCommand('Draft_Snap_Lock', Draft_Snap_Lock()) class Draft_Snap_Midpoint: """Command to snap to the midpoint of an edge.""" def GetResources(self): """Set icon, menu and tooltip.""" _menu = "Midpoint" _tip = "Snaps to midpoints of edges" return {'Pixmap': 'Snap_Midpoint', 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _menu), 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _tip)} def Activated(self): """Execute this when the command is called."""
) == coin.SoButtonEvent.UP: self.decreaseDegree() elif key == coin.SoKeyboardEvent.ESCAPE: self.abort() self.finish() def clic_cb(self, event_callback): event = event_callback.getEvent() if (type(event) == coin.SoMouseButtonEvent and event.getState() == coin.SoMouseButtonEvent.DOWN and event.getButton() == coin.SoMouseButtonEvent.BUTTON1): self.addPole() #FreeCADGui.Selection.clearSelection() def cursor_cb(self, event_callback): pos = FreeCADGui.ActiveDocument.ActiveView.getCursorPos() self.point = self.view.getPoint(pos[0], pos[1]) if self.snap: self.getSnapPoint(pos) self.cursorUpdate() def GetResources(self): return { 'Pixmap': path_curvesWB_icons + '/bezier.svg', 'MenuText': 'BSpline Curve', 'ToolTip': 'Creates a BSpline curve' } FreeCADGui.addCommand('bezierCurve', bezierCurve())
Gui.addModule("Draft") _cmd = 'Draft.make_fillet' _cmd += '(' _cmd += _wires + ', ' _cmd += 'radius=' + str(rad) if chamfer: _cmd += ', chamfer=' + str(chamfer) if delete: _cmd += ', delete=' + str(delete) _cmd += ')' _cmd_list = ['arc = ' + _cmd, 'Draft.autogroup(arc)', 'FreeCAD.ActiveDocument.recompute()'] self.commit(translate("draft", "Create fillet"), _cmd_list) def finish(self, close=False): """Terminate the operation.""" super(Fillet, self).finish() if self.ui: # self.linetrack.finalize() # self.arctrack.finalize() self.doc.recompute() Gui.addCommand('Draft_Fillet', Fillet()) ## @}
if hasattr(self,"Object"): g = self.Object.Group if child in g: g.remove(child) self.Object.Group = g class _ViewProviderFloor: "A View Provider for the Floor object" def __init__(self,vobj): vobj.Proxy = self def getIcon(self): import Arch_rc return ":/icons/Arch_Floor_Tree.svg" def attach(self,vobj): self.Object = vobj.Object return def claimChildren(self): return self.Object.Group def __getstate__(self): return None def __setstate__(self,state): return None if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Floor',_CommandFloor())
FreeCADGui.doCommand("import " + modul) FreeCADGui.doCommand("reload(" + modul +")") FreeCADGui.doCommand(self.command) else: FreeCADGui.doCommand("import Animation") FreeCADGui.doCommand("Animation.create"+self.name+"()") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() else: Msg("Erst Arbeitsbereich oeffnen") return if FreeCAD.GuiUp: FreeCADGui.addCommand('Anim_TA',_CommandActor("Interpolator",'/icons/icon1.svg',"Trackreader.runTA()","Trackreader")) FreeCADGui.addCommand('Anim_TB',_CommandActor("Fourier",'/icons/icon2.svg',"Trackreader.runTB()","Trackreader")) FreeCADGui.addCommand('Anim_TC',_CommandActor("Noise",'/icons/icon3.svg',"Trackreader.runTC()","Trackreader")) FreeCADGui.addCommand('Anim_Abroller',_CommandActor("Abroller",'/icons/abroller.png','Abroller.createAbroller()')) FreeCADGui.addCommand('Anim_Adjuster',_CommandActor('Adjuster','/icons/adjuster.png')) FreeCADGui.addCommand('Anim_Assembly2Controller',_CommandActor("Assembly2Controller",'/icons/assembly2SolveConstraints.svg',"Assembly2Controller.createAssembly2Controller()")) FreeCADGui.addCommand('Anim_Billboard',_CommandActor('Billboard', '/icons/billboard.png')) FreeCADGui.addCommand('Anim_Bounder',_CommandActor("Bounder",'/icons/bounder.png')) FreeCADGui.addCommand('Anim_Collider',_CommandActor("Collision",'/icons/collider.png',"Collision.createCollision()")) FreeCADGui.addCommand('Anim_Combiner',_CommandActor("Combiner",'/icons/combiner.png',"Combiner.createCombiner()")) FreeCADGui.addCommand('Anim_Connector',_CommandActor('Connector','/icons/scaler.png')) FreeCADGui.addCommand('Anim_ControlPanel',_CommandActor("AnimationControlPanel",'/icons/controlpanel.png',"AnimationControlPanel.createAnimationControlPanel()")) FreeCADGui.addCommand('Anim_Delta',_CommandActor("Delta",'/icons/delta.png')) FreeCADGui.addCommand('Anim_Diagram',_CommandActor("Diagram",'/icons/diagram.png',"Diagram.createDiagram()"))
return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} class Border: def Activated(self): import surfBorder surfBorder.load() def GetResources(self): from surfUtils import Paths, Translator IconPath = Paths.iconsPath() + "/BorderIco.png" MenuText = str(Translator.translate('Get border')) ToolTip = str(Translator.translate('Get edges from objects')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} class Convert: def Activated(self): import surfConvert surfConvert.load() def GetResources(self): from surfUtils import Paths, Translator IconPath = Paths.iconsPath() + "/ConvertIco.png" MenuText = str(Translator.translate('Convert to 4 sides surface')) ToolTip = str(Translator.translate('Convert a surface (or couple of them) into 4 sides surface')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} FreeCADGui.addCommand('Surf_IsoCurve', IsoCurve()) FreeCADGui.addCommand('Surf_SliceCurve', SliceCurve()) FreeCADGui.addCommand('Surf_Border', Border()) FreeCADGui.addCommand('Surf_Convert', Convert())
def Activated(self): FreeCAD.Console.PrintMessage("run ... ") import reconstruction.nurbs reload(reconstruction.nurbs) print "okay" reconstruction.nurbs.createnurbs() def GetResources(self): return { 'Pixmap': 'Std_Tool1', 'MenuText': 'Nurbs Editor', 'ToolTip': '' } FreeCADGui.addCommand('Nurbs Editor', nurbsEditor()) ''' class perspectiveTrafo: def Activated(self): FreeCAD.Console.PrintMessage("run ... ") import reconstruction.perspective_trafo reload(reconstruction.perspective_trafo) print "okay" reconstruction.perspective_trafo.run() def GetResources(self): return { 'Pixmap' : 'Std_Tool1', 'MenuText': 'Perspective Image Trafo ',
# result = self.exportObjectsWith(sublist[1], sublist[0], job, idx) # if result is None: # success = False # else: # gcode += result # else: # finalpostlist = [item for (_, slist) in postlist for item in slist] # gcode = self.exportObjectsWith(finalpostlist, "allitems", job, 1) # success = gcode is not None PathLog.track(success) if success: if hasattr(job, "LastPostProcessDate"): job.LastPostProcessDate = str(datetime.now()) if hasattr(job, "LastPostProcessOutput"): job.LastPostProcessOutput = " \n".join(filenames) PathLog.track(job.LastPostProcessOutput) FreeCAD.ActiveDocument.commitTransaction() else: FreeCAD.ActiveDocument.abortTransaction() FreeCAD.ActiveDocument.recompute() if FreeCAD.GuiUp: # register the FreeCAD command FreeCADGui.addCommand("Path_Post", CommandPathPost()) FreeCAD.Console.PrintLog("Loading PathPost... done\n")
class _Site(ArchFloor._Floor): "The Site object" def __init__(self,obj): ArchFloor._Floor.__init__(self,obj) obj.addProperty("App::PropertyLink","Terrain","Arch", str(translate("Arch","The terrain of this site"))) obj.addProperty("App::PropertyString","Address","Arch", str(translate("Arch","The address of this site"))) obj.addProperty("App::PropertyString","Coordinates","Arch", str(translate("Arch","The geographic coordinates of this site"))) obj.addProperty("App::PropertyString","Url","Arch", str(translate("Arch","An url that shows this site in a mapping website"))) self.Type = "Site" obj.setEditorMode('Height',2) class _ViewProviderSite(ArchFloor._ViewProviderFloor): "A View Provider for the Site object" def __init__(self,vobj): ArchFloor._ViewProviderFloor.__init__(self,vobj) def getIcon(self): import Arch_rc return ":/icons/Arch_Site_Tree.svg" def claimChildren(self): return self.Object.Group+[self.Object.Terrain] FreeCADGui.addCommand('Arch_Site',_CommandSite())
def createcmd(cmd='CV', pixmap='Std_Tool1', menutext=None, tooltip=None): global makeCV_master FreeCADGui.addCommand(cmd, makeCV_master(cmd, pixmap, menutext, tooltip)) cvCmds.append(cmd)
path = Path.Path(s) obj.Path = path class CommandPathCustom: def GetResources(self): return { "Pixmap": "Path-Custom", "MenuText": QtCore.QT_TRANSLATE_NOOP("Path_Custom", "Custom"), "ToolTip": QtCore.QT_TRANSLATE_NOOP("Path_Custom", "Creates a path object based on custom G-code"), } def IsActive(self): return not FreeCAD.ActiveDocument is None def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create Custom Path") FreeCADGui.addModule("PathScripts.PathCustom") FreeCADGui.addModule("PathScripts.PathUtils") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Custom")') FreeCADGui.doCommand("PathScripts.PathCustom.ObjectCustom(obj)") FreeCADGui.doCommand("obj.ViewObject.Proxy = 0") FreeCADGui.doCommand("PathScripts.PathUtils.addToProject(obj)") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() if FreeCAD.GuiUp: # register the FreeCAD command FreeCADGui.addCommand("Path_Custom", CommandPathCustom())
def c1(menu, name, *info): global _Command name1 = "Reconstruction_" + name t = _Command(name, *info) FreeCADGui.addCommand(name1, t) FreeCAD.tcmds6.append([menu, name1])
# Helpers def results_present(): results = False analysis_members = FemGui.getActiveAnalysis().Member for o in analysis_members: if o.isDerivedFrom('Fem::FemResultObject'): results = True return results def get_results_object(sel): if (len(sel) == 1): if sel[0].isDerivedFrom("Fem::FemResultObject"): return sel[0] for i in FemGui.getActiveAnalysis().Member: if(i.isDerivedFrom("Fem::FemResultObject")): return i return None if FreeCAD.GuiUp: FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis()) FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape()) FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl()) FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis()) FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis()) FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults()) FreeCADGui.addCommand('Fem_ShowResult', _CommandMechanicalShowResult())
def c2(menu, title, name, *info): print info global _Command title1 = "Reconstruction_" + title FreeCADGui.addCommand(title1, _Command(name, *info)) FreeCAD.tcmds6.append([menu, title1])
obj.addProperty("App::PropertyVectorList","w_o",obj.Name,"Points o to w",4).w_o = [vec] else: # mensaje de error para que el usuario fije unos ejes self.message() elif axis == 'h': if 'axis_h' in obj.PropertiesList: vec = obj.axis_h * value if 'h_o' in obj.PropertiesList: base = obj.h_o base.append(vec) obj.h_o = base else: obj.addProperty("App::PropertyVectorList","h_o",obj.Name,"Points o to h",4).h_o = [vec] else: # mensaje de error para que el usuario fije unos ejes self.message() else: # logger.error('Not working!!') pass else: logger.warning('FreeCAD version need to be 19 or newer to use this utility') def message(self): message = QtWidgets.QMessageBox() message.setText('The axes are not defined yet. Please set the axes first') message.setStandardButtons(QtWidgets.QMessageBox.Ok) message.setDefaultButton(QtWidgets.QMessageBox.Ok) message.exec_() # Command FreeCADGui.addCommand('New_Internal_Point', _New_Point_Cmd())
fsh.append(sh) obj.Shape = Part.makeCompound(fsh) # finalizing else: if base: if not base.isNull(): if base.isValid() and base.Solids: if base.Volume < 0: base.reverse() if base.Volume < 0: FreeCAD.Console.PrintError(str(translate("Arch","Couldn't compute the wall shape"))) return base = base.removeSplitter() obj.Shape = base if not DraftGeomUtils.isNull(pl): obj.Placement = pl class _ViewProviderStructure(ArchComponent.ViewProviderComponent): "A View Provider for the Structure object" def __init__(self,vobj): ArchComponent.ViewProviderComponent.__init__(self,vobj) def getIcon(self): import Arch_rc return ":/icons/Arch_Structure_Tree.svg" FreeCADGui.addCommand('Arch_Structure',_CommandStructure())
def writeCamera(self): if hasattr(self, "Object"): from pivy import coin n = FreeCADGui.ActiveDocument.ActiveView.getCameraNode() FreeCAD.Console.PrintMessage( QT_TRANSLATE_NOOP("Draft", "Writing camera position") + "\n") cdata = list(n.position.getValue().getValue()) cdata.extend(list(n.orientation.getValue().getValue())) cdata.append(n.nearDistance.getValue()) cdata.append(n.farDistance.getValue()) cdata.append(n.aspectRatio.getValue()) cdata.append(n.focalDistance.getValue()) if isinstance(n, coin.SoOrthographicCamera): cdata.append(n.height.getValue()) cdata.append(0.0) # orthograhic camera elif isinstance(n, coin.SoPerspectiveCamera): cdata.append(n.heightAngle.getValue()) cdata.append(1.0) # perspective camera self.Object.ViewObject.ViewData = cdata def __getstate__(self): return None def __setstate__(self, state): return None if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_BuildingPart', CommandBuildingPart())
def getDisplayModes(self,vobj): modes=["Default"] return modes def setDisplayMode(self,mode): return mode def getDXF(self,obj): "returns a DXF representation of the view" if obj.RenderingMode == "Solid": print "Unable to get DXF from Solid mode: ",obj.Label return "" result = [] import Drawing if not hasattr(self,"baseshape"): self.onChanged(obj,"Source") if hasattr(self,"baseshape"): if self.baseshape: result.append(Drawing.projectToDXF(self.baseshape,self.direction)) if hasattr(self,"sectionshape"): if self.sectionshape: result.append(Drawing.projectToDXF(self.sectionshape,self.direction)) if hasattr(self,"hiddenshape"): if self.hiddenshape: result.append(Drawing.projectToDXF(self.hiddenshape,self.direction)) return result if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_SectionPlane',_CommandSectionPlane())
if s.isDerivedFrom("Path::Feature"): incl.append(s) obj = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython","Compound") PathScripts.PathCompoundExtended.ObjectCompoundExtended(obj) PathScripts.PathCompoundExtended.ViewProviderCompoundExtended(obj.ViewObject) project = PathUtils.addToProject(obj) if incl: children = [] p = project.Group g = obj.Group for child in incl: p.remove(child) children.append(FreeCAD.ActiveDocument.getObject(child.Name)) project.Group = p g.append(children) obj.Group = children ''' FreeCADGui.doCommand(snippet) FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() if FreeCAD.GuiUp: # register the FreeCAD command FreeCADGui.addCommand('Path_CompoundExtended', CommandCompoundExtended()) FreeCAD.Console.PrintLog("Loading PathCompoundExtended... done\n")
if FreeCAD.GuiUp: import FreeCADGui from PySide import QtCore class _CommandMeshFromShape(FemCommands): # the Fem_MeshFromShape command definition def __init__(self): super(_CommandMeshFromShape, self).__init__() self.resources = {'Pixmap': 'fem-fem-mesh-from-shape', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MeshFromShape", "FEM mesh from shape"), 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MeshFromShape", "Create a FEM volume mesh from a solid shape")} self.is_active = 'with_part_feature' def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create FEM mesh") FreeCADGui.addModule("FemGui") sel = FreeCADGui.Selection.getSelection() if (len(sel) == 1): if(sel[0].isDerivedFrom("Part::Feature")): FreeCADGui.doCommand("App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject', '" + sel[0].Name + "_Mesh')") FreeCADGui.doCommand("App.activeDocument().ActiveObject.Shape = App.activeDocument()." + sel[0].Name) FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)") FreeCADGui.Selection.clearSelection() if FreeCAD.GuiUp: FreeCADGui.addCommand('Fem_MeshFromShape', _CommandMeshFromShape())
class _CommandShellThickness(FemCommands): "The Fem_ShellThickness command definition" def __init__(self): super(_CommandShellThickness, self).__init__() self.resources = { 'Pixmap': 'fem-shell-thickness', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_ShellThickness", "Shell plate thickness"), 'Accel': "C, S", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_ShellThickness", "Creates a FEM shell plate thickness") } self.is_active = 'with_analysis' def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create FemShellThickness") FreeCADGui.addModule("FemShellThickness") FreeCADGui.doCommand( "FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemShellThickness.makeFemShellThickness()]" ) FreeCADGui.addCommand('Fem_ShellThickness', _CommandShellThickness())
if len(FreeCADGui.Selection.getSelection()) > 1: return True else: return False def Activated(self): sel = FreeCADGui.Selection.getSelection() FreeCAD.ActiveDocument.openTransaction(str(translate("Arch", "Grouping"))) host = sel.pop() for o in sel: FreeCADGui.doCommand("import Arch") FreeCADGui.doCommand( "Arch.addFixture(FreeCAD.ActiveDocument." + o.Name + ",FreeCAD.ActiveDocument." + host.Name + ")" ) FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() if FreeCAD.GuiUp: FreeCADGui.addCommand("Arch_Add", _CommandAdd()) FreeCADGui.addCommand("Arch_Remove", _CommandRemove()) FreeCADGui.addCommand("Arch_SplitMesh", _CommandSplitMesh()) FreeCADGui.addCommand("Arch_MeshToShape", _CommandMeshToShape()) FreeCADGui.addCommand("Arch_SelectNonSolidMeshes", _CommandSelectNonSolidMeshes()) FreeCADGui.addCommand("Arch_RemoveShape", _CommandRemoveShape()) FreeCADGui.addCommand("Arch_CloseHoles", _CommandCloseHoles()) FreeCADGui.addCommand("Arch_Check", _CommandCheck()) FreeCADGui.addCommand("Arch_IfcExplorer", _CommandIfcExplorer()) FreeCADGui.addCommand("Arch_Survey", _CommandSurvey()) # FreeCADGui.addCommand('Arch_Fixture',_CommandFixture())
def retranslateUi(self, TaskPanel): TaskPanel.setWindowTitle( QtGui.QApplication.translate("Arch", "Roof", None, QtGui.QApplication.UnicodeUTF8)) self.title.setText( QtGui.QApplication.translate( "Arch", "Parameters of the profiles of the roof:\n* Angle : slope in degrees compared to the horizontal one.\n* Run : outdistance between the wall and the ridge sheathing.\n* Thickness : thickness of the side of roof.\n* Overhang : outdistance between the sewer and the wall.\n* Height : height of the ridge sheathing (calculated automatically)\n* IdRel : Relative Id for calculations automatic.\n---\nIf Angle = 0 and Run = 0 then profile is identical to the relative profile.\nIf Angle = 0 then angle is calculated so that the height is the same one as the relative profile.\nIf Run = 0 then Run is calculated so that the height is the same one as the relative profile.", None, QtGui.QApplication.UnicodeUTF8)) self.tree.setHeaderLabels([ QtGui.QApplication.translate("Arch", "Id", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Run", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "IdRel", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Thickness", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Overhang", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Height", None, QtGui.QApplication.UnicodeUTF8) ]) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Roof', _CommandRoof())
FreeCAD.Console.PrintError(translate("PathPocket","Please select only edges or a single face\n")) return if selection[0].SubObjects[0].ShapeType == "Edge": try: import Part w = Part.Wire(selection[0].SubObjects) except: FreeCAD.Console.PrintError(translate("PathPocket","The selected edges don't form a loop\n")) return # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction(translate("PathPocket","Create Pocket")) FreeCADGui.addModule("PathScripts.PathPocket") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Pocket")') FreeCADGui.doCommand('PathScripts.PathPocket.ObjectPocket(obj)') subs = "[" for s in selection[0].SubElementNames: subs += '"' + s + '",' subs += "]" FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].ObjectName + ',' + subs + ')') FreeCADGui.doCommand('obj.ViewObject.Proxy = 0') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() if FreeCAD.GuiUp: # register the FreeCAD command FreeCADGui.addCommand('Path_Pocket',CommandPathPocket()) FreeCAD.Console.PrintLog("Loading PathPocket... done\n")
else: g.buttonenabled = False selObv.SelObserverOFF() viewob.vooff() def Deactivated(self): """This function is executed when the workbench is deactivated.""" selObv.SelObserverOFF() viewob.vooff() def IsChecked(self): return(g.buttonenabled) def IsActive(self): return(True) FreeCADGui.addCommand('rnp_OneButton', rnp_OneButton()) #============================================================================== class mApp(QtGui.QWidget): """This message box was added to make this file a standalone file""" # for error messages def __init__(self, msg, msgtype='ok'): super().__init__() self.title = 'Warning' self.left = 100 self.top = 100 self.width = 400 self.height = 300 self.initUI(msg) def initUI(self, msg):
FreeCADGui.doCommand("MagicPart.recompute([_ftr])") if P.autosel: FreeCADGui.doCommand("MagicPart.select([_ftr])") else: ftr = mask(sel[0]) if need_recompute: recompute([ftr]) if P.autosel: select([ftr]) def IsActive(self): return len(FreeCADGui.Selection.getSelection()) > 0 FreeCADGui.addCommand("MagicPart_common", CommonCommand()) FreeCADGui.addCommand("MagicPart_fuse", FuseCommand()) FreeCADGui.addCommand("MagicPart_cut", CutCommand()) FreeCADGui.addCommand("MagicPart_complement", ComplementCommand()) FreeCADGui.addCommand("MagicPart_transform", TransformCommand()) FreeCADGui.addCommand("MagicPart_partition", PartitionCommand()) FreeCADGui.addCommand("MagicPart_fragment", FragmentCommand()) FreeCADGui.addCommand("MagicPart_slice", SliceCommand()) FreeCADGui.addCommand("MagicPart_compound", CompoundCommand()) FreeCADGui.addCommand("MagicPart_compoundRemove", CompoundRemoveCommand()) FreeCADGui.addCommand("MagicPart_compoundFuse", CompoundFuseCommand()) FreeCADGui.addCommand("MagicPart_compoundTranform", CompoundTransformCommand()) FreeCADGui.addCommand("MagicPart_apart", ApartCommand()) FreeCADGui.addCommand("MagicPart_mask", MaskCommand()) oplist = ["MagicPart_common",
return {"name": self.Object.Name} def __setstate__(self, state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return None class CompSpringCommand: """Creates a Parametric Compression Spring""" def makeFeature(self): fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "CompSpring") CompSpringFP(fp) CompSpringVP(fp.ViewObject) FreeCAD.ActiveDocument.recompute() def Activated(self): self.makeFeature() def IsActive(self): if FreeCAD.ActiveDocument: return True else: return False def GetResources(self): return {'Pixmap': TOOL_ICON, 'MenuText': __title__, 'ToolTip': __doc__} FreeCADGui.addCommand('comp_spring', CompSpringCommand())