clearZ = 0
actionList = []
for item in self.list:
- if item.profile != None and os.path.isfile(item.profile):
+ if item.profile is not None and os.path.isfile(item.profile):
profile.loadGlobalProfile(item.profile)
put('object_center_x', item.centerX - self.extruderOffset[item.extruder][0])
put('object_center_y', item.centerY - self.extruderOffset[item.extruder][1])
actionList[-2].leaveResultForNextSlice = True
actionList[-1].usePreviousSlice = True
- if item.profile != None:
+ if item.profile is not None:
profile.loadGlobalProfileFromString(oldProfile)
else:
actionList = []
action = Action()
- action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl")
- action.centerX = profile.getPreferenceFloat('machine_width') / 2
- action.centerY = profile.getPreferenceFloat('machine_depth') / 2
+ action.sliceCmd = sliceRun.getSliceCommand(resultFilename, [resultFilename + "_temp_.stl"], [profile.getMachineCenterCoords()])
+ action.centerX = profile.getMachineCenterCoords()[0]
+ action.centerY = profile.getMachineCenterCoords()[1]
action.temperature = profile.getProfileSettingFloat('print_temperature')
action.extruder = 0
action.filename = resultFilename + "_temp_.stl"
self.startTime = time.time()
if profile.getPreference('save_profile') == 'True':
profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
- center = profile.getMachineCenterCoords()
+ center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
cmdList = [sliceRun.getSliceCommand(sliceRun.getExportFilename(self.filelist[0]), ['|'.join(self.filelist)], [center])]
self.thread = WorkerThread(self, filelist, cmdList)
def getProfileInformation():
return {
'carve': {
- 'Add_Layer_Template_to_SVG': DEFSET,
+ 'Add_Layer_Template_to_SVG': 'False',
'Edge_Width_mm': calculateEdgeWidth,
'Extra_Decimal_Places_float': DEFSET,
'Import_Coarseness_ratio': DEFSET,
'Correct_Mesh': DEFSET,
'Unproven_Mesh': DEFSET,
'SVG_Viewer': DEFSET,
- 'FlipX': storedSetting("flip_x"),
- 'FlipY': storedSetting("flip_y"),
- 'FlipZ': storedSetting("flip_z"),
- 'SwapXZ': storedSetting("swap_xz"),
- 'SwapYZ': storedSetting("swap_yz"),
- 'Scale': storedSettingFloat("model_scale"),
- 'Rotate': storedSettingFloat("model_rotate_base"),
+ 'ObjectMatrix': storedSetting("object_matrix"),
'CenterX': lambda setting: profile.getProfileSettingFloat('object_center_x') if profile.getProfileSettingFloat('object_center_x') > 0 else profile.getPreferenceFloat("machine_width") / 2,
'CenterY': lambda setting: profile.getProfileSettingFloat('object_center_y') if profile.getProfileSettingFloat('object_center_y') > 0 else profile.getPreferenceFloat("machine_depth") / 2,
'AlternativeCenterFile': storedSetting("alternative_center"),
settings.LabelSeparator().getFromRepository(self)
self.executeTitle = 'Carve'
- self.flipX = settings.BooleanSetting().getFromValue('FlipX', self, False)
- self.flipY = settings.BooleanSetting().getFromValue('FlipY', self, False)
- self.flipZ = settings.BooleanSetting().getFromValue('FlipZ', self, False)
- self.swapXZ = settings.BooleanSetting().getFromValue('SwapXZ', self, False)
- self.swapYZ = settings.BooleanSetting().getFromValue('SwapYZ', self, False)
- self.centerX = settings.FloatSpin().getFromValue(0.0, 'CenterX', self, 1000.0, 0.0)
- self.centerY = settings.FloatSpin().getFromValue(0.0, 'CenterY', self, 1000.0, 0.0)
- self.scale = settings.FloatSpin().getFromValue( 0.1, 'Scale', self, 10.0, 1.0 )
- self.rotate = settings.FloatSpin().getFromValue( -180.0, 'Rotate', self, 180.0, 0.0 )
+ self.centerX = settings.FloatSpin().getFromValue(0.0, 'CenterX', self, 1000.0, 0.0);
+ self.centerY = settings.FloatSpin().getFromValue(0.0, 'CenterY', self, 1000.0, 0.0);
+ self.matrix = settings.StringSetting().getFromValue('ObjectMatrix', self, '1,0,0,0,1,0,0,0,1')
self.alternativeCenter = settings.StringSetting().getFromValue('AlternativeCenterFile', self, '')
def getCarvedSVG(self, carving, fileName, repository):
"Parse gnu triangulated surface text and store the carved gcode."
- scale = repository.scale.value
- rotate = repository.rotate.value / 180 * math.pi
- scaleX = scale
- scaleY = scale
- scaleZ = scale
- if repository.flipX.value == True:
- scaleX = -scaleX
- if repository.flipY.value == True:
- scaleY = -scaleY
- if repository.flipZ.value == True:
- scaleZ = -scaleZ
- swapXZ = repository.swapXZ.value
- swapYZ = repository.swapYZ.value
- mat00 = math.cos(rotate) * scaleX
- mat01 =-math.sin(rotate) * scaleY
- mat10 = math.sin(rotate) * scaleX
- mat11 = math.cos(rotate) * scaleY
+ matrix = map(float, repository.matrix.value.split(','))
+ print matrix
for i in xrange(0, len(carving.vertexes)):
x = carving.vertexes[i].x
y = carving.vertexes[i].y
z = carving.vertexes[i].z
- if swapXZ:
- x, z = z, x
- if swapYZ:
- y, z = z, y
carving.vertexes[i] = Vector3(
- x * mat00 + y * mat01,
- x * mat10 + y * mat11,
- z * scaleZ)
+ x * matrix[0] + y * matrix[3] + z * matrix[6],
+ x * matrix[1] + y * matrix[4] + z * matrix[7],
+ x * matrix[2] + y * matrix[5] + z * matrix[8])
if repository.alternativeCenter.value != '':
carving2 = svg_writer.getCarving(repository.alternativeCenter.value)
x = carving2.vertexes[i].x
y = carving2.vertexes[i].y
z = carving2.vertexes[i].z
- if swapXZ:
- x, z = z, x
- if swapYZ:
- y, z = z, y
carving2.vertexes[i] = Vector3(
- x * mat00 + y * mat01,
- x * mat10 + y * mat11,
- z * scaleZ)
+ x * matrix[0] + y * matrix[3] + z * matrix[6],
+ x * matrix[1] + y * matrix[4] + z * matrix[7],
+ x * matrix[2] + y * matrix[5] + z * matrix[8])
minZ = carving2.getMinimumZ()
minSize = carving2.getCarveCornerMinimum()
maxSize = carving2.getCarveCornerMaximum()
import math
import numpy
+numpy.seterr(all='ignore')
from Cura.util import util3d
mat = numpy.array([mat[2],mat[1],mat[0]], numpy.float32)
if swapYZ:
mat = numpy.array([mat[0],mat[2],mat[1]], numpy.float32)
+ self.matrix = mat
self.vertexes = (numpy.matrix(self.origonalVertexes, copy = False) * numpy.matrix(mat)).getA()
#Calculate the boundery box of the object
return int(math.ceil(solidThickness / layerHeight - 0.0001))
def getMachineCenterCoords():
- return (getPreferenceFloat('machine_width') / 2, getPreferenceFloat('machine_depth') / 2)
+ return [getPreferenceFloat('machine_width') / 2, getPreferenceFloat('machine_depth') / 2]
+
+def getObjectMatrix():
+ rotate = getProfileSettingFloat('model_rotate_base')
+ rotate = rotate / 180.0 * math.pi
+ scaleX = 1.0
+ scaleY = 1.0
+ scaleZ = 1.0
+ if getProfileSetting('flipX') == 'True':
+ scaleX = -scaleX
+ if getProfileSetting('flipY') == 'True':
+ scaleY = -scaleY
+ if getProfileSetting('flipZ') == 'True':
+ scaleZ = -scaleZ
+ mat00 = math.cos(rotate) * scaleX
+ mat01 =-math.sin(rotate) * scaleY
+ mat10 = math.sin(rotate) * scaleX
+ mat11 = math.cos(rotate) * scaleY
+
+ mat = [mat00,mat10,0, mat01,mat11,0, 0,0,scaleZ]
+ if getProfileSetting('swap_xz') == 'True':
+ mat = mat[6:9] + mat[3:6] + mat[0:3]
+ if getProfileSetting('swap_yz') == 'True':
+ mat = mat[0:3] + mat[6:9] + mat[3:6]
+ return mat
#########################################################
## Alteration file functions
for idx in xrange(0, len(filenames)):
filename = filenames[idx]
position = positions[idx]
- cmd.append("%f,%f" % (position[0], position[1]))
+ cmd.append(','.join(map(str, position)))
try:
cmd.append(str(filename))
except UnicodeEncodeError: