This commit is contained in:
Thomas-Alexandre Moreau 2025-01-30 12:33:49 +01:00
parent cb4870666b
commit e6d9eae3a1

33
Calepinage.FCMacro Normal file → Executable file
View file

@ -44,25 +44,27 @@ class WindowDialog():
isSVGFull = False
YBlockCounter = 0
SVGNameCounter = 1
maxY = 0
index = 0
listSize = len(copy_sketchList)
while len(copy_sketchList) > 0:
maxY = 0.0
counter = 0
for __O__ in copy_sketchList:
while listSize > 0:
while index < (listSize - 1):
print(f'{copy_sketchList} --- {listSize}')
__O__ = copy_sketchList[index]
boundingBox = __O__.Shape.BoundBox
if boundingBox.XLength + currentX > plateLength:
counter += 1
index += 1
continue
if boundingBox.YLength + currentY > plateWidth:
YBlockCounter += 1
if YBlockCounter >= len(copy_sketchList):
if YBlockCounter >= listSize:
isSVGFull = True
break
index += 1
continue
__obj__.insert(0, __O__)
maxY = boundingBox.YLength if boundingBox.YLength > maxY else maxY
oldPlace = __obj__[0].Placement
__obj__[0].Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(1,0,0),0), App.Vector(0,0,0))
if currentX == 0.0:
__obj__[0].Placement.Base = FreeCAD.Vector(currentX, currentY, 0.0)
@ -70,28 +72,35 @@ class WindowDialog():
__obj__[0].Placement.Base = FreeCAD.Vector(currentX + spacing, currentY, 0.0)
currentX += boundingBox.XLength
copy_sketchList.pop(counter)
counter += 1
copy_sketchList.pop(index)
listSize = len(copy_sketchList)
App.activeDocument().recompute()
index = 0
currentY += maxY + spacing
index = 0
listSize = len(copy_sketchList)
App.activeDocument().recompute()
if len(copy_sketchList) == 0 or isSVGFull:
if listSize <= 0 or isSVGFull:
fichierSVG = u"" + outputRacine + '--CALEPINAGE-' + str(SVGNameCounter) + '.svg'
print('Export SVG de : --CALEPINAGE-' + str(SVGNameCounter) + '.svg')
importSVG.export(__obj__, fichierSVG)
for __i__ in __obj__:
for i in __obj__:
App.ActiveDocument.removeObject(__i__.Label)
App.activeDocument().recompute()
__obj__.clear()
maxY = 0.0
index = 0
currentX = 0.0
currentY = 0.0
isSVGFull = False
SVGNameCounter += 1
SVGBlockCounter = 0
listSize = len(copy_sketchList)
# -------- END -------- #