-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathat_export_config.py
47 lines (34 loc) · 1.52 KB
/
at_export_config.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
import FreeCAD, FreeCADGui
from arch_texture_utils.resource_utils import iconPath
import arch_texture_utils.qtutils as qtutils
from arch_texture_utils.selection_utils import findSelectedTextureConfig
class ExportTextureConfigCommand:
toolbarName = 'ArchTexture_Tools'
commandName = 'Export_Config'
def GetResources(self):
return {'MenuText': "Export Texture Config",
'ToolTip' : "Exports the configuration stored inside a TextureConfig object to a file",
'Pixmap': iconPath('ExportConfig.svg')
}
def Activated(self):
textureConfig = findSelectedTextureConfig()
if textureConfig is None:
qtutils.showInfo("No TextureConfig selected", "Select exactly one TextureConfig object to export its content")
return
selectedFile = qtutils.userSelectedFile('Export Location', qtutils.JSON_FILES, False)
if selectedFile is None:
return
fileObject = open(selectedFile, 'w')
textureConfig.export(fileObject)
def IsActive(self):
"""If there is no active document we can't do anything."""
return not FreeCAD.ActiveDocument is None
if __name__ == "__main__":
command = ExportTextureConfigCommand();
if command.IsActive():
command.Activated()
else:
qtutils.showInfo("No open Document", "There is no open document")
else:
import archtexture_toolbars
archtexture_toolbars.toolbarManager.registerCommand(ExportTextureConfigCommand())