add sub folders for time, removed time on files name, started working on a rec function but not working atm
This commit is contained in:
parent
55e586bcc6
commit
0396dd5f58
|
|
@ -90,9 +90,17 @@ class WindowDialog():
|
|||
break
|
||||
|
||||
|
||||
def _createFolder(self, date):
|
||||
def _createFolder(self):
|
||||
date = datetime.today().strftime('%Y-%m-%d')
|
||||
time = datetime.today().strftime('%H:%M:%S')
|
||||
|
||||
folderPath = f"{FreeCAD.activeDocument().getFileName().rpartition('.')[0]}-{date}-Exports/"
|
||||
|
||||
if not os.path.exists(folderPath):
|
||||
os.makedirs(folderPath)
|
||||
|
||||
folderPath += f"{time}/"
|
||||
|
||||
if not os.path.exists(folderPath):
|
||||
os.makedirs(folderPath)
|
||||
|
||||
|
|
@ -101,20 +109,20 @@ class WindowDialog():
|
|||
|
||||
# -------- MODIFICATION DE LA MACRO "exportSketchEnMasse-SVG" de Gauthier Brière -------- #
|
||||
|
||||
def _exportSketchBasic(self, sketchList, date):
|
||||
def _exportSketchBasic(self, sketchList):
|
||||
for __O__ in sketchList:
|
||||
__obj__ = []
|
||||
__obj__.append(__O__)
|
||||
|
||||
print('Export SVG de : ' + __obj__[0].Label)
|
||||
|
||||
fichierSVG = u"" + self.outputRacine + __obj__[0].Label + '-' + date + '.svg'
|
||||
fichierSVG = u"" + self.outputRacine + __obj__[0].Label + '-' + '.svg'
|
||||
importSVG.export(__obj__, fichierSVG)
|
||||
FreeCAD.ActiveDocument.removeObject(__O__.Label)
|
||||
|
||||
FreeCAD.activeDocument().recompute()
|
||||
|
||||
def _exportSketchCalepinage(self, sketchList, plateLength, plateWidth, spacing, date):
|
||||
def _exportSketchCalepinage(self, sketchList, plateLength, plateWidth, spacing):
|
||||
copy_sketchList = sketchList[:]
|
||||
__obj__ = []
|
||||
currentX = 0.0
|
||||
|
|
@ -178,8 +186,8 @@ class WindowDialog():
|
|||
FreeCAD.activeDocument().recompute()
|
||||
|
||||
if listSize <= 0 or isSVGFull:
|
||||
fichierSVG = u"" + self.outputRacine + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + date + '.svg'
|
||||
print('Export SVG de : ' + u"" + str(os.path.basename(self.outputRacine)) + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + date + '.svg')
|
||||
fichierSVG = u"" + self.outputRacine + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + '.svg'
|
||||
print('Export SVG de : ' + u"" + str(os.path.basename(self.outputRacine)) + 'CALEPINAGE-' + str(SVGNameCounter) + '-' + '.svg')
|
||||
importSVG.export(__obj__, fichierSVG)
|
||||
for __i__ in __obj__:
|
||||
FreeCAD.ActiveDocument.removeObject(__i__.Label)
|
||||
|
|
@ -202,7 +210,23 @@ class WindowDialog():
|
|||
|
||||
# -------- END -------- #
|
||||
|
||||
def exportSVG(self, isCalepinage, date):
|
||||
def searchDir(self, obj, x = 0.0, y = 0.0, z = 0.0):
|
||||
x1, y1, z1 = x, y, z
|
||||
|
||||
if hasattr(obj, 'Dir'):
|
||||
if obj.Dir.x != 0.0:
|
||||
x1 = obj.Dir.x
|
||||
if obj.Dir.y != 0.0:
|
||||
y1 = obj.Dir.y
|
||||
if obj.Dir.z != 0.0:
|
||||
z1 = obj.Dir.z
|
||||
if hasattr(obj, 'Objects'):
|
||||
for i in obj.Objects:
|
||||
self.searchDir(i, x1, y1, z1)
|
||||
|
||||
return FreeCAD.Vector(x1, y1, z1)
|
||||
|
||||
def exportSVG(self, isCalepinage):
|
||||
plateLength = self.form.doubleSpinBoxLength.value()
|
||||
plateWidth = self.form.doubleSpinBoxWidth.value()
|
||||
spacing = self.form.doubleSpinBoxSpacing.value()
|
||||
|
|
@ -222,13 +246,8 @@ class WindowDialog():
|
|||
break
|
||||
|
||||
for _ in range(count):
|
||||
if hasattr(obj, 'Dir'):
|
||||
sv0 = Draft.make_shape2dview(obj, FreeCAD.Vector(obj.Dir))
|
||||
elif hasattr(obj, 'Objects'):
|
||||
for child in obj.Objects:
|
||||
if hasattr(child, 'Dir'):
|
||||
sv0 = Draft.make_shape2dview(child, FreeCAD.Vector(child.Dir))
|
||||
break
|
||||
vector = self.searchDir(obj)
|
||||
sv0 = Draft.make_shape2dview(obj, vector)
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
sk = Draft.make_sketch(sv0, autoconstraints=True)
|
||||
|
|
@ -240,15 +259,15 @@ class WindowDialog():
|
|||
FreeCAD.ActiveDocument.removeObject(sv0.Name)
|
||||
|
||||
if isCalepinage:
|
||||
self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing, date)
|
||||
self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing)
|
||||
else:
|
||||
self._exportSketchBasic(sketchList, date)
|
||||
self._exportSketchBasic(sketchList)
|
||||
|
||||
self._populate_selector_list()
|
||||
|
||||
|
||||
|
||||
def exportSTL(self, singleMode, date):
|
||||
def exportSTL(self, singleMode):
|
||||
objects_to_export = []
|
||||
|
||||
for obj in FreeCADGui.Selection.getSelection():
|
||||
|
|
@ -271,7 +290,7 @@ class WindowDialog():
|
|||
|
||||
if not singleMode:
|
||||
for obj, label, i in objects_to_export:
|
||||
filename = os.path.join(self.outputRacine, f"{label}_{i}-{date}.stl")
|
||||
filename = os.path.join(self.outputRacine, f"{label}_{i}.stl")
|
||||
Mesh.export([obj], filename)
|
||||
print(f"Exported STL: {filename}")
|
||||
FreeCAD.ActiveDocument.removeObject(obj.Name)
|
||||
|
|
@ -279,7 +298,7 @@ class WindowDialog():
|
|||
export_objs = [obj for obj, _, _ in objects_to_export]
|
||||
if export_objs:
|
||||
label = FreeCAD.activeDocument().Name
|
||||
filename = os.path.join(self.outputRacine, f"{label}-{date}.stl")
|
||||
filename = os.path.join(self.outputRacine, f"{label}.stl")
|
||||
Mesh.export(export_objs, filename)
|
||||
print(f"Exported merged STL: {filename}")
|
||||
for obj in export_objs:
|
||||
|
|
@ -293,13 +312,10 @@ class WindowDialog():
|
|||
isCalepinage = self.form.checkBoxCalepinage.isChecked()
|
||||
isCombine = self.form.checkBoxCombine.isChecked()
|
||||
|
||||
dateFolder = datetime.today().strftime('%Y-%m-%d')
|
||||
dateFiles = datetime.today().strftime('%H:%M:%S')
|
||||
self.outputRacine = self._createFolder()
|
||||
|
||||
self.outputRacine = self._createFolder(dateFolder)
|
||||
|
||||
self.exportSVG(isCalepinage, dateFiles)
|
||||
self.exportSTL(isCombine, dateFiles)
|
||||
self.exportSVG(isCalepinage)
|
||||
self.exportSTL(isCombine)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in a new issue