added STL export + renaming files
This commit is contained in:
parent
f3771fa94b
commit
9faf22650e
|
|
@ -1,141 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Calepinage</class>
|
|
||||||
<widget class="QWidget" name="Dialog">
|
|
||||||
<property name="windowModality">
|
|
||||||
<enum>Qt::WindowModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>200</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string notr="true">Calepinage</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="locale">
|
|
||||||
<locale language="French" country="France"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Longueur du plateau (mm) :</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxLength">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>50.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label2">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Largeur du plateau (mm) :</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxWidth">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>50.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label3">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Espacement (mm) :</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxSpacing">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>5.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label4">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Epaisseur du laser (mm) :</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxLaserSize">
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>5.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButtonCalepinage">
|
|
||||||
<property name="text">
|
|
||||||
<string>Calepinage</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QPushButton" name="pushButtonSVG">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export en .svg
|
|
||||||
(sans calepinage)</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
|
|
@ -3,17 +3,27 @@ import FreeCAD
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
import Draft
|
import Draft
|
||||||
import os
|
import os
|
||||||
|
import svgpathtools
|
||||||
|
from svgpathtools import svg2paths
|
||||||
|
from shapely.geometry import LineString
|
||||||
|
from lxml import etree
|
||||||
|
from shapely.ops import unary_union
|
||||||
|
import Mesh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WindowDialog():
|
class WindowDialog():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ui_file = os.path.join(FreeCAD.getUserMacroDir(True), 'Calepinage/Calepinage.ui')
|
self.ui_file = os.path.join(FreeCAD.getUserMacroDir(True), 'MultiExport/MultiExport.ui')
|
||||||
self.form = FreeCADGui.PySideUic.loadUi(self.ui_file)
|
self.form = FreeCADGui.PySideUic.loadUi(self.ui_file)
|
||||||
self._connect_widgets()
|
self._connect_widgets()
|
||||||
self.form.show()
|
self.form.show()
|
||||||
|
|
||||||
def _connect_widgets(self):
|
def _connect_widgets(self):
|
||||||
self.form.pushButtonSVG.pressed.connect(lambda: self.export(False))
|
self.form.pushButtonSVG.pressed.connect(lambda: self.exportSVG(False))
|
||||||
self.form.pushButtonCalepinage.pressed.connect(lambda: self.export(True))
|
self.form.pushButtonCalepinage.pressed.connect(lambda: self.exportSVG(True))
|
||||||
|
self.form.pushButtonSTLSingle.pressed.connect(lambda: self.exportSTL(True))
|
||||||
|
self.form.pushButtonSTLMulti.pressed.connect(lambda: self.exportSTL(False))
|
||||||
|
|
||||||
# -------- MODIFICATION DE LA MACRO "exportSketchEnMasse-SVG" de Gauthier Brière -------- #
|
# -------- MODIFICATION DE LA MACRO "exportSketchEnMasse-SVG" de Gauthier Brière -------- #
|
||||||
|
|
||||||
|
|
@ -126,7 +136,7 @@ class WindowDialog():
|
||||||
|
|
||||||
# -------- MODIFICATION DE MA MACRO "QuickSVGExport" -------- #
|
# -------- MODIFICATION DE MA MACRO "QuickSVGExport" -------- #
|
||||||
|
|
||||||
def export(self, isCalepinage):
|
def exportSVG(self, isCalepinage):
|
||||||
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()
|
||||||
|
|
@ -156,6 +166,28 @@ class WindowDialog():
|
||||||
|
|
||||||
# -------- END -------- #
|
# -------- END -------- #
|
||||||
|
|
||||||
|
def exportSTL(self, singleMode):
|
||||||
|
outputRacine = App.activeDocument().getFileName().rpartition('.')[0]
|
||||||
|
__obj__ = []
|
||||||
|
for selectedObject in FreeCADGui.Selection.getSelectionEx():
|
||||||
|
__obj__.append(selectedObject.Object)
|
||||||
|
if not singleMode:
|
||||||
|
filename = u"" + outputRacine + '--' + __obj__[0].Label + '.stl'
|
||||||
|
if hasattr(Mesh, "exportOptions"):
|
||||||
|
options = Mesh.exportOptions(outputRacine)
|
||||||
|
Mesh.export(__obj__, filename, options)
|
||||||
|
else:
|
||||||
|
Mesh.export(__obj__, filename)
|
||||||
|
__obj__.clear()
|
||||||
|
if singleMode:
|
||||||
|
filename = u"" + outputRacine + '--' + __obj__[0].Label + '.stl' if len(__obj__) == 1 else u"" + outputRacine + '.stl'
|
||||||
|
if hasattr(Mesh, "exportOptions"):
|
||||||
|
options = Mesh.exportOptions(outputRacine)
|
||||||
|
Mesh.export(__obj__, filename, options)
|
||||||
|
else:
|
||||||
|
Mesh.export(__obj__, filename)
|
||||||
|
del __obj__
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
207
MultiExport/MultiExport.ui
Normal file
207
MultiExport/MultiExport.ui
Normal file
|
|
@ -0,0 +1,207 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MultiExport</class>
|
||||||
|
<widget class="QWidget" name="Dialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>300</width>
|
||||||
|
<height>250</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string notr="true">Multi Exporting</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
|
||||||
|
<item row="16" column="0" colspan="3">
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string notr="true">Export SVG</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="French" country="France" />
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Longueur du plateau (mm) :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxLength">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>50.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label2">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Largeur du plateau (mm) :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxWidth">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>50.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label3">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Espacement (mm) :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxSpacing">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>5.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label4">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Epaisseur du laser (mm) :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxLaserSize">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>5.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButtonCalepinage">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export en .svg (calepinage)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButtonSVG">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export en .svg (sans calepinage)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string notr="true">Export STL</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButtonSTLSingle">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export en .stl (single)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButtonSTLMulti">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export en .stl (multi)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources />
|
||||||
|
<connections />
|
||||||
|
</ui>
|
||||||
Loading…
Reference in a new issue