added date (format HH:MM:SS) on exported files
This commit is contained in:
parent
7fc535c119
commit
55e586bcc6
|
|
@ -90,8 +90,8 @@ class WindowDialog():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def _createFolder(self):
|
def _createFolder(self, date):
|
||||||
folderPath = f"{FreeCAD.activeDocument().getFileName().rpartition('.')[0]}-{datetime.today().strftime('%Y-%m-%d')}-Exports/"
|
folderPath = f"{FreeCAD.activeDocument().getFileName().rpartition('.')[0]}-{date}-Exports/"
|
||||||
|
|
||||||
if not os.path.exists(folderPath):
|
if not os.path.exists(folderPath):
|
||||||
os.makedirs(folderPath)
|
os.makedirs(folderPath)
|
||||||
|
|
@ -101,20 +101,20 @@ class WindowDialog():
|
||||||
|
|
||||||
# -------- MODIFICATION DE LA MACRO "exportSketchEnMasse-SVG" de Gauthier Brière -------- #
|
# -------- MODIFICATION DE LA MACRO "exportSketchEnMasse-SVG" de Gauthier Brière -------- #
|
||||||
|
|
||||||
def _exportSketchBasic(self, sketchList):
|
def _exportSketchBasic(self, sketchList, date):
|
||||||
for __O__ in sketchList:
|
for __O__ in sketchList:
|
||||||
__obj__ = []
|
__obj__ = []
|
||||||
__obj__.append(__O__)
|
__obj__.append(__O__)
|
||||||
|
|
||||||
print('Export SVG de : ' + __obj__[0].Label)
|
print('Export SVG de : ' + __obj__[0].Label)
|
||||||
|
|
||||||
fichierSVG = u"" + self.outputRacine + __obj__[0].Label + '.svg'
|
fichierSVG = u"" + self.outputRacine + __obj__[0].Label + '-' + date + '.svg'
|
||||||
importSVG.export(__obj__, fichierSVG)
|
importSVG.export(__obj__, fichierSVG)
|
||||||
FreeCAD.ActiveDocument.removeObject(__O__.Label)
|
FreeCAD.ActiveDocument.removeObject(__O__.Label)
|
||||||
|
|
||||||
FreeCAD.activeDocument().recompute()
|
FreeCAD.activeDocument().recompute()
|
||||||
|
|
||||||
def _exportSketchCalepinage(self, sketchList, plateLength, plateWidth, spacing):
|
def _exportSketchCalepinage(self, sketchList, plateLength, plateWidth, spacing, date):
|
||||||
copy_sketchList = sketchList[:]
|
copy_sketchList = sketchList[:]
|
||||||
__obj__ = []
|
__obj__ = []
|
||||||
currentX = 0.0
|
currentX = 0.0
|
||||||
|
|
@ -178,8 +178,8 @@ class WindowDialog():
|
||||||
FreeCAD.activeDocument().recompute()
|
FreeCAD.activeDocument().recompute()
|
||||||
|
|
||||||
if listSize <= 0 or isSVGFull:
|
if listSize <= 0 or isSVGFull:
|
||||||
fichierSVG = u"" + self.outputRacine + 'CALEPINAGE-' + str(SVGNameCounter) + '.svg'
|
fichierSVG = u"" + self.outputRacine + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + date + '.svg'
|
||||||
print('Export SVG de : ' + u"" + str(os.path.basename(self.outputRacine)) + 'CALEPINAGE-' + str(SVGNameCounter) + '.svg')
|
print('Export SVG de : ' + u"" + str(os.path.basename(self.outputRacine)) + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + date + '.svg')
|
||||||
importSVG.export(__obj__, fichierSVG)
|
importSVG.export(__obj__, fichierSVG)
|
||||||
for __i__ in __obj__:
|
for __i__ in __obj__:
|
||||||
FreeCAD.ActiveDocument.removeObject(__i__.Label)
|
FreeCAD.ActiveDocument.removeObject(__i__.Label)
|
||||||
|
|
@ -202,7 +202,7 @@ class WindowDialog():
|
||||||
|
|
||||||
# -------- END -------- #
|
# -------- END -------- #
|
||||||
|
|
||||||
def exportSVG(self, isCalepinage):
|
def exportSVG(self, isCalepinage, date):
|
||||||
plateLength = self.form.doubleSpinBoxLength.value()
|
plateLength = self.form.doubleSpinBoxLength.value()
|
||||||
plateWidth = self.form.doubleSpinBoxWidth.value()
|
plateWidth = self.form.doubleSpinBoxWidth.value()
|
||||||
spacing = self.form.doubleSpinBoxSpacing.value()
|
spacing = self.form.doubleSpinBoxSpacing.value()
|
||||||
|
|
@ -240,15 +240,15 @@ class WindowDialog():
|
||||||
FreeCAD.ActiveDocument.removeObject(sv0.Name)
|
FreeCAD.ActiveDocument.removeObject(sv0.Name)
|
||||||
|
|
||||||
if isCalepinage:
|
if isCalepinage:
|
||||||
self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing)
|
self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing, date)
|
||||||
else:
|
else:
|
||||||
self._exportSketchBasic(sketchList)
|
self._exportSketchBasic(sketchList, date)
|
||||||
|
|
||||||
self._populate_selector_list()
|
self._populate_selector_list()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def exportSTL(self, singleMode):
|
def exportSTL(self, singleMode, date):
|
||||||
objects_to_export = []
|
objects_to_export = []
|
||||||
|
|
||||||
for obj in FreeCADGui.Selection.getSelection():
|
for obj in FreeCADGui.Selection.getSelection():
|
||||||
|
|
@ -271,7 +271,7 @@ class WindowDialog():
|
||||||
|
|
||||||
if not singleMode:
|
if not singleMode:
|
||||||
for obj, label, i in objects_to_export:
|
for obj, label, i in objects_to_export:
|
||||||
filename = os.path.join(self.outputRacine, f"{label}_{i}.stl")
|
filename = os.path.join(self.outputRacine, f"{label}_{i}-{date}.stl")
|
||||||
Mesh.export([obj], filename)
|
Mesh.export([obj], filename)
|
||||||
print(f"Exported STL: {filename}")
|
print(f"Exported STL: {filename}")
|
||||||
FreeCAD.ActiveDocument.removeObject(obj.Name)
|
FreeCAD.ActiveDocument.removeObject(obj.Name)
|
||||||
|
|
@ -279,7 +279,7 @@ class WindowDialog():
|
||||||
export_objs = [obj for obj, _, _ in objects_to_export]
|
export_objs = [obj for obj, _, _ in objects_to_export]
|
||||||
if export_objs:
|
if export_objs:
|
||||||
label = FreeCAD.activeDocument().Name
|
label = FreeCAD.activeDocument().Name
|
||||||
filename = os.path.join(self.outputRacine, f"{label}.stl")
|
filename = os.path.join(self.outputRacine, f"{label}-{date}.stl")
|
||||||
Mesh.export(export_objs, filename)
|
Mesh.export(export_objs, filename)
|
||||||
print(f"Exported merged STL: {filename}")
|
print(f"Exported merged STL: {filename}")
|
||||||
for obj in export_objs:
|
for obj in export_objs:
|
||||||
|
|
@ -293,10 +293,13 @@ class WindowDialog():
|
||||||
isCalepinage = self.form.checkBoxCalepinage.isChecked()
|
isCalepinage = self.form.checkBoxCalepinage.isChecked()
|
||||||
isCombine = self.form.checkBoxCombine.isChecked()
|
isCombine = self.form.checkBoxCombine.isChecked()
|
||||||
|
|
||||||
self.outputRacine = self._createFolder()
|
dateFolder = datetime.today().strftime('%Y-%m-%d')
|
||||||
|
dateFiles = datetime.today().strftime('%H:%M:%S')
|
||||||
|
|
||||||
self.exportSVG(isCalepinage)
|
self.outputRacine = self._createFolder(dateFolder)
|
||||||
self.exportSTL(isCombine)
|
|
||||||
|
self.exportSVG(isCalepinage, dateFiles)
|
||||||
|
self.exportSTL(isCombine, dateFiles)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue