mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-05 18:10:44 +08:00
Update preferences to allow math expressions. Fixed #86
This commit is contained in:
parent
8f39846349
commit
11d9022741
@ -47,7 +47,7 @@ class previewPanel(wx.Panel):
|
|||||||
self.objectsMinV = None
|
self.objectsMinV = None
|
||||||
self.objectsMaxV = None
|
self.objectsMaxV = None
|
||||||
self.loadThread = None
|
self.loadThread = None
|
||||||
self.machineSize = util3d.Vector3(float(profile.getPreference('machine_width')), float(profile.getPreference('machine_depth')), float(profile.getPreference('machine_height')))
|
self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))
|
||||||
self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0)
|
self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0)
|
||||||
|
|
||||||
self.toolbar = toolbarUtil.Toolbar(self)
|
self.toolbar = toolbarUtil.Toolbar(self)
|
||||||
|
@ -39,15 +39,15 @@ class projectPlanner(wx.Frame):
|
|||||||
self.list = []
|
self.list = []
|
||||||
self.selection = None
|
self.selection = None
|
||||||
|
|
||||||
self.machineSize = util3d.Vector3(float(profile.getPreference('machine_width')), float(profile.getPreference('machine_depth')), float(profile.getPreference('machine_height')))
|
self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))
|
||||||
self.headSizeMin = util3d.Vector3(float(profile.getPreference('extruder_head_size_min_x')), float(profile.getPreference('extruder_head_size_min_y')),0)
|
self.headSizeMin = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0)
|
||||||
self.headSizeMax = util3d.Vector3(float(profile.getPreference('extruder_head_size_max_x')), float(profile.getPreference('extruder_head_size_max_y')),0)
|
self.headSizeMax = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_max_x'), profile.getPreferenceFloat('extruder_head_size_max_y'),0)
|
||||||
|
|
||||||
self.extruderOffset = [
|
self.extruderOffset = [
|
||||||
util3d.Vector3(0,0,0),
|
util3d.Vector3(0,0,0),
|
||||||
util3d.Vector3(float(profile.getPreference('extruder_offset_x1')), float(profile.getPreference('extruder_offset_y1')), 0),
|
util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x1'), profile.getPreferenceFloat('extruder_offset_y1'), 0),
|
||||||
util3d.Vector3(float(profile.getPreference('extruder_offset_x2')), float(profile.getPreference('extruder_offset_y2')), 0),
|
util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x2'), profile.getPreferenceFloat('extruder_offset_y2'), 0),
|
||||||
util3d.Vector3(float(profile.getPreference('extruder_offset_x3')), float(profile.getPreference('extruder_offset_y3')), 0)]
|
util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x3'), profile.getPreferenceFloat('extruder_offset_y3'), 0)]
|
||||||
|
|
||||||
self.toolbar = toolbarUtil.Toolbar(self)
|
self.toolbar = toolbarUtil.Toolbar(self)
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ class sliceProgessPanel(wx.Panel):
|
|||||||
if idx > 0:
|
if idx > 0:
|
||||||
profile.putProfileSetting('fan_enabled', 'False')
|
profile.putProfileSetting('fan_enabled', 'False')
|
||||||
profile.putProfileSetting('skirt_line_count', '0')
|
profile.putProfileSetting('skirt_line_count', '0')
|
||||||
profile.putProfileSetting('machine_center_x', profile.getProfileSettingFloat('machine_center_x') - float(profile.getPreference('extruder_offset_x%d' % (idx))))
|
profile.putProfileSetting('machine_center_x', profile.getProfileSettingFloat('machine_center_x') - profile.getPreferenceFloat('extruder_offset_x%d' % (idx)))
|
||||||
profile.putProfileSetting('machine_center_y', profile.getProfileSettingFloat('machine_center_y') - float(profile.getPreference('extruder_offset_y%d' % (idx))))
|
profile.putProfileSetting('machine_center_y', profile.getProfileSettingFloat('machine_center_y') - profile.getPreferenceFloat('extruder_offset_y%d' % (idx)))
|
||||||
profile.putProfileSetting('alternative_center', self.filelist[0])
|
profile.putProfileSetting('alternative_center', self.filelist[0])
|
||||||
if len(self.filelist) > 1:
|
if len(self.filelist) > 1:
|
||||||
profile.putProfileSetting('add_start_end_gcode', 'False')
|
profile.putProfileSetting('add_start_end_gcode', 'False')
|
||||||
|
@ -36,11 +36,11 @@ class gcode():
|
|||||||
#Calculates the weight of the filament in kg
|
#Calculates the weight of the filament in kg
|
||||||
radius = float(profile.getProfileSetting('filament_diameter')) / 2
|
radius = float(profile.getProfileSetting('filament_diameter')) / 2
|
||||||
volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
|
volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
|
||||||
return volumeM3 * float(profile.getPreference('filament_density'))
|
return volumeM3 * profile.getPreferenceFloat('filament_density')
|
||||||
|
|
||||||
def calculateCost(self):
|
def calculateCost(self):
|
||||||
cost_kg = float(profile.getPreference('filament_cost_kg'))
|
cost_kg = profile.getPreferenceFloat('filament_cost_kg')
|
||||||
cost_meter = float(profile.getPreference('filament_cost_meter'))
|
cost_meter = profile.getPreferenceFloat('filament_cost_meter')
|
||||||
if cost_kg > 0.0 and cost_meter > 0.0:
|
if cost_kg > 0.0 and cost_meter > 0.0:
|
||||||
return "%.2f / %.2f" % (self.calculateWeight() * cost_kg, self.extrusionAmount / 1000 * cost_meter)
|
return "%.2f / %.2f" % (self.calculateWeight() * cost_kg, self.extrusionAmount / 1000 * cost_meter)
|
||||||
elif cost_kg > 0.0:
|
elif cost_kg > 0.0:
|
||||||
@ -94,12 +94,12 @@ class gcode():
|
|||||||
T = self.getCodeInt(line, 'T')
|
T = self.getCodeInt(line, 'T')
|
||||||
if T is not None:
|
if T is not None:
|
||||||
if currentExtruder > 0:
|
if currentExtruder > 0:
|
||||||
posOffset.x -= float(profile.getPreference('extruder_offset_x%d' % (currentExtruder)))
|
posOffset.x -= profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
|
||||||
posOffset.y -= float(profile.getPreference('extruder_offset_y%d' % (currentExtruder)))
|
posOffset.y -= profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
|
||||||
currentExtruder = T
|
currentExtruder = T
|
||||||
if currentExtruder > 0:
|
if currentExtruder > 0:
|
||||||
posOffset.x += float(profile.getPreference('extruder_offset_x%d' % (currentExtruder)))
|
posOffset.x += profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
|
||||||
posOffset.y += float(profile.getPreference('extruder_offset_y%d' % (currentExtruder)))
|
posOffset.y += profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
|
||||||
|
|
||||||
G = self.getCodeInt(line, 'G')
|
G = self.getCodeInt(line, 'G')
|
||||||
if G is not None:
|
if G is not None:
|
||||||
|
@ -236,6 +236,13 @@ globalPreferenceParser = None
|
|||||||
def getPreferencePath():
|
def getPreferencePath():
|
||||||
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
|
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
|
||||||
|
|
||||||
|
def getPreferenceFloat(name):
|
||||||
|
try:
|
||||||
|
return float(eval(getPreference(name), {}, {}))
|
||||||
|
|
||||||
|
except (ValueError, SyntaxError):
|
||||||
|
return 0.0
|
||||||
|
|
||||||
def getPreference(name):
|
def getPreference(name):
|
||||||
global globalPreferenceParser
|
global globalPreferenceParser
|
||||||
if globalPreferenceParser == None:
|
if globalPreferenceParser == None:
|
||||||
@ -346,7 +353,7 @@ def getAlterationFileContents(filename):
|
|||||||
if filename == 'start.gcode':
|
if filename == 'start.gcode':
|
||||||
#For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
|
#For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
|
||||||
#We also set our steps per E here, if configured.
|
#We also set our steps per E here, if configured.
|
||||||
eSteps = float(getPreference('steps_per_e'))
|
eSteps = getPreferenceFloat('steps_per_e')
|
||||||
if eSteps > 0:
|
if eSteps > 0:
|
||||||
prefix += 'M92 E%f\n' % (eSteps)
|
prefix += 'M92 E%f\n' % (eSteps)
|
||||||
temp = getProfileSettingFloat('print_temperature')
|
temp = getProfileSettingFloat('print_temperature')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user