This repository has been archived by the owner on Jun 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
export_elementary_volume.py
66 lines (48 loc) · 1.87 KB
/
export_elementary_volume.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QApplication
from qgis.PyQt.QtGui import QCursor
from qgis.core import QgsFeatureRequest
FORM_CLASS, _ = uic.loadUiType(
os.path.join(os.path.dirname(__file__), "export_elementary_volume.ui")
)
class ExportElementaryVolume(QDialog, FORM_CLASS):
def __init__(self, layer, project, graph, parent=None):
super(ExportElementaryVolume, self).__init__(parent)
self.setupUi(self)
self.cell_layer = layer
self.project = project
self.graph = graph
self.mSelect.clicked.connect(self.__select)
self.mButtonBox.accepted.connect(self.__export)
def __select(self):
dlg = QFileDialog()
dlg.setFileMode(QFileDialog.Directory)
filenames = []
if dlg.exec_():
filenames = dlg.selectedFiles()
if filenames:
filename = filenames[0]
self.mOutputDir.setText(filename)
def __export(self):
fids = self.cell_layer.allFeatureIds()
if self.mSelection.isChecked():
fids = self.cell_layer.selectedFeaturesIds()
closed_only = self.mClosedVolume.isChecked()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
cell_ids = [feature["id"]
for fid in fids
for feature in self.cell_layer.getFeatures(QgsFeatureRequest(fid))
]
outdir = self.mOutputDir.text()
if self.mFormat.currentText() == "OBJ":
self.project.export_elementary_volume_obj(
self.graph, cell_ids, outdir, closed_only
)
else: # DXF
self.project.export_elementary_volume_dxf(
self.graph, cell_ids, outdir, closed_only
)
QApplication.restoreOverrideCursor()