Python FreeCAD.ParamGet() Examples
The following are 30
code examples of FreeCAD.ParamGet().
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
FreeCAD
, or try the search function
.
Example #1
Source File: Command.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def Activated(self): # Grab our code editor so we can interact with it cqCodePane = Shared.getActiveCodePane() # If there are no windows open there is nothing to save if cqCodePane == None: FreeCAD.Console.PrintError("Nothing to save.\r\n") return # If the code pane doesn't have a filename, we need to present the save as dialog if len(cqCodePane.get_path()) == 0 or os.path.basename(cqCodePane.get_path()) == 'script_template.py' \ or os.path.split(cqCodePane.get_path())[0].endswith('FreeCAD'): FreeCAD.Console.PrintError("You cannot save over a blank file, example file or template file.\r\n") CadQuerySaveAsScript().Activated() return # Rely on our export library to help us save the file ExportCQ.save() # Execute the script if the user has asked for it if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").GetBool("executeOnSave"): CadQueryExecuteScript().Activated()
Example #2
Source File: SettingsDialog.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def acceptSettings(self): FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").SetInt("fontSize", self.ui_font_size.value()) FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").SetString("executeKeybinding", self.ui_key_binding.text()) FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").SetBool("executeOnSave", self.execute_on_save.checkState()) FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").SetBool("showLineNumbers", self.show_line_numbers.checkState()) FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").SetBool("allowReload", self.allow_reload.checkState()) self.accept() # def getValues(self): # return { # 'max': self.ui_max.value(), # 'min': self.ui_min.value(), # 'count': self.ui_count.value(), # } # def setValues(self, settings): # self.ui_max.setValue(settings['max']) # self.ui_min.setValue(settings['min']) # self.ui_count.setValue(settings['count'])
Example #3
Source File: checkBOP-example.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 6 votes |
def checkBOP(shape): """ checking BOP errors of a shape returns: - True if Shape is Valid - the Shape errors """ # enabling BOP check paramGt = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Part/CheckGeometry") paramGt.SetBool("RunBOPCheck",True) try: shape.check(True) return True except: return sys.exc_info()[1] #ValueError #sys.exc_info() #False ##
Example #4
Source File: cq_cad_tools.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 6 votes |
def checkBOP(shape): """ checking BOP errors of a shape returns: - True if Shape is Valid - the Shape errors """ # enabling BOP check paramGt = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Part/CheckGeometry") paramGt.SetBool("RunBOPCheck",True) try: shape.check(True) return True except Exception: return sys.exc_info()[1] #ValueError #sys.exc_info() #False ## #from an argument string, extract a list of numbers #numbers can be individual e.g. "3" #numbers can be comma delimited e.g. "3,5" #numbers can be in a range e.g. "3-8" #numbers can't be < 1
Example #5
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 6 votes |
def unit_factor( self, unit_text, customScaleValue): if unit_text != 'custom': if unit_text == 'Edit->Preference->Unit': #found using FreeCAD.ParamGet("User parameter:BaseApp/Preferences").Export('/tmp/p3') UserSchema = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("UserSchema") v = FreeCAD.Units.Quantity(1, FreeCAD.Units.Length ).getUserPreferred()[1] else: UserSchema = ['mm','m','inch'].index( unit_text ) if UserSchema == 0: #standard (mm/kg/s/degree v = 1.0 elif UserSchema == 1: #standard (m/kg/s/degree) v = 1000.0 else: #either US customary, or Imperial decimal v = 25.4 else: v = customScaleValue return 1.0/v if v != 0 else 1.0
Example #6
Source File: SheetMetalUnfolder.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 6 votes |
def Activated(self): try: taskd = SMUnfoldTaskPanel() except ValueError as e: SMErrorBox(e.args[0]) return pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/sheetmetal") if pg.GetBool("bendSketch"): taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Checked) else: taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Unchecked) if pg.GetBool("genSketch"): taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Checked) else: taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Unchecked) taskd.bendColor.setColor(pg.GetString("bendColor")) taskd.genColor.setColor(pg.GetString("genColor")) taskd.internalColor.setColor(pg.GetString("intColor")) FreeCADGui.Control.showDialog(taskd) return
Example #7
Source File: SheetMetalUnfolder.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 6 votes |
def Activated(self): SMMessage("Running unattended unfold...") try: taskd = SMUnfoldTaskPanel() except ValueError as e: SMErrorBox(e.args[0]) return pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/sheetmetal") if pg.GetBool("bendSketch"): taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Checked) else: taskd.checkSeparate.setCheckState(QtCore.Qt.CheckState.Unchecked) if pg.GetBool("genSketch"): taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Checked) else: taskd.checkSketch.setCheckState(QtCore.Qt.CheckState.Unchecked) taskd.bendColor.setColor(pg.GetString("bendColor")) taskd.genColor.setColor(pg.GetString("genColor")) taskd.internalColor.setColor(pg.GetString("intColor")) taskd.new_mds_name = taskd.material_sheet_name taskd.accept() return
Example #8
Source File: engineering_mode.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 5 votes |
def engineering_mode_enabled(): FSParam = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/SheetMetal") return FSParam.GetInt("EngineeringUXMode", 0) # 0 = disabled, 1 = enabled
Example #9
Source File: CodeEditor.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def slotDirChanged(self, path): allowReload = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").GetBool("allowReload") # Make sure that the contents of our file actually changed if self.changedOnDisk() and allowReload: FreeCAD.Console.PrintMessage("Contents of " + self.file_path + " changed, reloading \r\n") self.reload()
Example #10
Source File: grid.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self): self.dd_parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Drawing_Dimensioning")
Example #11
Source File: grid.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def update(self): try: if hasattr( self, 'SVG'): self.remove() drawingVars = self.drawingVars parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Drawing_Dimensioning") div_period = parms.GetInt( 'grid_display_period',default_grid_display_period ) lineWidth = parms.GetFloat( 'grid_line_width', default_grid_line_width ) if parms.GetBool('grid_on', False) and div_period > 0 and lineWidth > 0: self.SVG = QtSvg.QGraphicsSvgItem() self.SVGRenderer = QtSvg.QSvgRenderer() dArg ='' div = parms.GetFloat( 'grid_spacing', default_grid_spacing ) clr = unsignedToRGBText(parms.GetUnsigned( 'grid_color', default_grid_clr )) W = drawingVars.width / drawingVars.VRT_scale H = drawingVars.height / drawingVars.VRT_scale for i in range(1, int(W / (div*div_period) )+1): dArg = dArg + ' M %f 0 L %f %f' % (i*div*div_period, i*div*div_period, H) for i in range(1, int(H / (div*div_period) )+1): dArg = dArg + ' M 0 %f L %f %f' % (i*div*div_period, W, i*div*div_period) self.SVGRenderer.load( QtCore.QByteArray( '''<svg width="%i" height="%i"> <path stroke="%srgb(0, 255, 0)" stroke-width="%f" d="%s"/> </svg>''' % (drawingVars.width, drawingVars.height, clr, lineWidth, dArg) ) ) self.SVG.setSharedRenderer( self.SVGRenderer ) self.SVG.setTransform( drawingVars.transform ) self.SVG.setZValue( 0.08 ) #ensure behind dimension preview SVG ... drawingVars.graphicsScene.addItem( self.SVG ) #FreeCAD.Console.PrintMessage('Grid Svg Added to Scene\n') except: FreeCAD.Console.PrintError(traceback.format_exc())
Example #12
Source File: grid.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def applyGridRounding( x, y): parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Drawing_Dimensioning") if parms.GetBool('grid_on', False): #then alter x and y div = parms.GetFloat( 'grid_spacing', 5 ) new_x = x - x%div new_y = y - y%div return new_x, new_y else: return x, y
Example #13
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, dimensioningProcess, endFunction_parm_name): self.d = dimensioningProcess self.endFunction = dimensioningProcess.endFunction self.parmName = endFunction_parm_name self.defaultValue = True self.dd_parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Drawing_Dimensioning")
Example #14
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, name, defaultValue, label, **extraKWs): self.name = name self.defaultValue = defaultValue self.label = label if label != None else name self.category = "Parameters" # for the freecad property category self.dd_parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Drawing_Dimensioning") self.process_extraKWs(**extraKWs) self.initExtra()
Example #15
Source File: GDT.py From FreeCAD-GDT with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, obj): obj.addProperty("App::PropertyFloat","LineWidth","GDT","Line width").LineWidth = getLineWidth() obj.addProperty("App::PropertyColor","LineColor","GDT","Line color").LineColor = getRGBLine() obj.addProperty("App::PropertyFloat","LineScale","GDT","Line scale").LineScale = getParam("lineScale",1.0) obj.addProperty("App::PropertyLength","FontSize","GDT","Font size").FontSize = getTextSize() obj.addProperty("App::PropertyString","FontName","GDT","Font name").FontName = getTextFamily() obj.addProperty("App::PropertyColor","FontColor","GDT","Font color").FontColor = getRGBText() obj.addProperty("App::PropertyInteger","Decimals","GDT","The number of decimals to show").Decimals = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2) obj.addProperty("App::PropertyBool","ShowUnit","GDT","Show the unit suffix").ShowUnit = getParam("showUnit",True) _ViewProviderGDT.__init__(self,obj)
Example #16
Source File: Keyboard.py From Animation with GNU General Public License v2.0 | 5 votes |
def __init__(self,ctl=None): QtCore.QObject.__init__(self) self.V=ctl.src self.ctl=ctl self.keypressed=False self.stack=[] self.editmode=False self.pos=None #self.debug=False self.debug=FreeCAD.ParamGet('User parameter:Plugins').GetBool('EventFilterDebug') self.debug=True
Example #17
Source File: Animation.py From Animation with GNU General Public License v2.0 | 5 votes |
def step(self,nw): if self.obj2.start<=nw and nw<=self.obj2.start + self.obj2.intervall: say("step " + self.obj2.Label + " " + str(nw)) t=FreeCAD.ActiveDocument.getObject(self.obj2.Name) intervall=self.obj2.intervall if self.obj2.Label == self.obj2.Name: s= s=self.obj2.Label else: s=self.obj2.Label + ' ('+ self.obj2.Name +")" say(s +" !************************* manager run loop:" + str(nw-self.obj2.start) + "/" + str(intervall)) self.obj2.step=nw #if os.path.exists("/tmp/stop"): if FreeCAD.ParamGet('User parameter:Plugins/animation').GetBool("stop"): say("notbremse gezogen") raise Exception("Notbremse Manager main loop") for ob in t.OutList: if 1: # fehler analysieren sayd("step fuer ") sayd(ob.Label) if ob.ViewObject.Visibility: ob.Proxy.step(nw) else: try: sayd(ob.Proxy) if ob.ViewObject.Visibility: ob.Proxy.step(nw) except: say("fehler step 2") raise Exception("step nicht ausfuerbar") FreeCAD.ActiveDocument.recompute() print("deaktivate updateGui()--------------------------------------------------!") #FreeCADGui.updateGui() time.sleep(self.obj2.sleeptime)
Example #18
Source File: Animation.py From Animation with GNU General Public License v2.0 | 5 votes |
def run(self,intervall=-1): sayd("run intervall=" + str(intervall)) FreeCADGui.ActiveDocument.ActiveView.setAnimationEnabled(False) if (intervall<0): intervall=self.obj2.intervall if hasattr(self,'obj2'): t=FreeCAD.ActiveDocument.getObject(self.obj2.Name) else: raise Exception("obj2 not found --> reinit the file!") for ob in t.OutList: say(ob.Label) ob.Proxy.initialize() ob.Proxy.execute(ob) firstRun=True bigloop=0 #while firstRun or os.path.exists("/tmp/loop"): while firstRun or FreeCAD.ParamGet('User parameter:Plugins/animation').GetBool("loop"): say("manager infinite loop #################################") firstRun=False bigloop += 1 for nw in range(self.obj2.start): say("---- manager before" + str(nw)) for nw in range(intervall+1): self.step(nw) FreeCAD.ActiveDocument.recompute() FreeCADGui.updateGui() time.sleep(self.obj2.sleeptime) FreeCADGui.Selection.clearSelection() FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.getObject(self.obj2.Name))
Example #19
Source File: Animation.py From Animation with GNU General Public License v2.0 | 5 votes |
def stopManager(vobj=None): # fname='/tmp/stop' # fhandle = open(fname, 'a') # fhandle.close() ta=FreeCAD.ParamGet('User parameter:Plugins/animation') ta.SetBool("stop",True)
Example #20
Source File: Animation.py From Animation with GNU General Public License v2.0 | 5 votes |
def unlockManager(vobj=None): # import os # from os import remove # fname='/tmp/stop' # try: # os.remove(fname) # except: # pass ta=FreeCAD.ParamGet('User parameter:Plugins/animation') ta.SetBool("stop",False)
Example #21
Source File: Animation.py From Animation with GNU General Public License v2.0 | 5 votes |
def unloopManager(vobj=None): # import os # from os import remove # fname='/tmp/loop' # try: # os.remove(fname) # except: # pass ta=FreeCAD.ParamGet('User parameter:Plugins/animation') ta.SetBool("loop",False)
Example #22
Source File: GDT.py From FreeCAD-GDT with GNU Lesser General Public License v2.1 | 5 votes |
def getParam(param,default=None): "getParam(parameterName): returns a GDT parameter value from the current config" p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/GDT") t = getParamType(param) if t == "int": if default == None: default = 0 return p.GetInt(param,default) elif t == "string": if default == None: default = "" return p.GetString(param,default) elif t == "float": if default == None: default = 1 return p.GetFloat(param,default) elif t == "bool": if default == None: default = False return p.GetBool(param,default) elif t == "unsigned": if default == None: default = 0 return p.GetUnsigned(param,default) else: return None
Example #23
Source File: GDT.py From FreeCAD-GDT with GNU Lesser General Public License v2.1 | 5 votes |
def setParam(param,value): "setParam(parameterName,value): sets a GDT parameter with the given value" p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/GDT") t = getParamType(param) if t == "int": p.SetInt(param,value) elif t == "string": p.SetString(param,value) elif t == "float": p.SetFloat(param,value) elif t == "bool": p.SetBool(param,value) elif t == "unsigned": p.SetUnsigned(param,value) #--------------------------------------------------------------------------- # General functions #---------------------------------------------------------------------------
Example #24
Source File: gui.py From FreeCAD_assembly3 with GNU General Public License v3.0 | 5 votes |
def __init__(self): self._attached = False self.timer = QtCore.QTimer() self.timer.setSingleShot(True) self.timer.timeout.connect(self.onTimer) self.cmds = [] self.elements = dict() self.attach() # Check for SoFCSwitch to see if we are running in a version of FC that # actually supports ShowSelectionOnTop. if coin.SoType.fromName("SoFCSwitch").isBad(): self.viewParam = None else: self.viewParam = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/View')
Example #25
Source File: a2plib.py From A2plus with GNU Lesser General Public License v2.1 | 5 votes |
def getRecursiveUpdateEnabled(): preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/A2plus") return preferences.GetBool('enableRecursiveUpdate',False) #------------------------------------------------------------------------------
Example #26
Source File: gui.py From FreeCAD_assembly3 with GNU General Public License v3.0 | 5 votes |
def getToolbarParams(): return FreeCAD.ParamGet('User parameter:BaseApp/MainWindow/Toolbars')
Example #27
Source File: gui.py From FreeCAD_assembly3 with GNU General Public License v3.0 | 5 votes |
def getParamGroup(mcs): return FreeCAD.ParamGet( 'User parameter:BaseApp/Preferences/Mod/Assembly3')
Example #28
Source File: gui.py From FreeCAD_assembly3 with GNU General Public License v3.0 | 5 votes |
def importMode(cls): params = FreeCAD.ParamGet( 'User parameter:BaseApp/Preferences/Mod/Import') mode = params.GetInt('ImportMode',0) if not mode: mode = 2 return mode
Example #29
Source File: qForms.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,winTitle='Rotate WP', icon='rotWP.svg'): super(rotWPForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.grid=QGridLayout() self.setLayout(self.grid) self.radioX=QRadioButton('X') self.radioX.setChecked(True) self.radioY=QRadioButton('Y') self.radioZ=QRadioButton('Z') self.lab1=QLabel('Angle:') self.edit1=QLineEdit('45') self.edit1.setAlignment(Qt.AlignCenter) self.edit1.setValidator(QDoubleValidator()) self.btn1=QPushButton('Rotate working plane') self.btn1.clicked.connect(self.rotate) self.grid.addWidget(self.radioX,0,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioY,0,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioZ,0,2,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab1,1,0,1,1) self.grid.addWidget(self.edit1,1,1,1,2) self.grid.addWidget(self.btn1,2,0,1,3,Qt.AlignCenter) self.show() self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] from polarUtilsCmd import arrow self.arrow =arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
Example #30
Source File: pipeForms.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def offsetWP(self): if hasattr(FreeCAD,'DraftWorkingPlane') and hasattr(FreeCADGui,'Snapper'): s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] varrow =polarUtilsCmd.arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s) offset=QInputDialog.getInteger(None,'Offset Work Plane','Offset: ') if offset[1]: polarUtilsCmd.offsetWP(offset[0]) FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().removeChild(varrow.node)