Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalle-Samuli Riihikoski <haikalle@gmail.com>2020-11-23 10:46:20 +0300
committerKalle-Samuli Riihikoski <haikalle@gmail.com>2020-11-23 10:46:20 +0300
commit348467f8e3880783a1badb09ecfe07afaeb03753 (patch)
tree28c82bd773a6416b5413f2aac4b3684f16c177a2 /io_coat3D
parent075a0e12cdc06c99079bf8867304b23fe2e1fb60 (diff)
io_coat3D: better exchange folder set up
Diffstat (limited to 'io_coat3D')
-rw-r--r--io_coat3D/__init__.py50
-rw-r--r--io_coat3D/folders.py35
2 files changed, 68 insertions, 17 deletions
diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index d766ffc7..28e8f711 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -60,7 +60,7 @@ from bpy.props import (
StringProperty,
PointerProperty,
)
-
+only_one_time = True
global_exchange_folder = ''
foundExchangeFolder = True
saved_exchange_folder = ''
@@ -73,6 +73,11 @@ def every_3_seconds():
global global_exchange_folder
global liveUpdate
global mTime
+ global only_one_time
+
+ if(only_one_time):
+ only_one_time = False
+ folders.loadExchangeFolder()
try:
@@ -88,9 +93,6 @@ def every_3_seconds():
tex.updatetextures(objekti)
mTime = os.path.getmtime(Export_folder)
-
- if (os.path.normpath(global_exchange_folder) != os.path.normpath(coat3D.exchangeFolder) and coat3D.exchangeFolder != ''):
- folders.updateExchangeFile(coat3D.exchangeFolder)
except:
pass
@@ -223,7 +225,7 @@ class SCENE_OT_getback(bpy.types.Operator):
bl_label = "Export your custom property"
bl_description = "Export your custom property"
bl_options = {'UNDO'}
-
+
def invoke(self, context, event):
global global_exchange_folder
@@ -256,6 +258,32 @@ class SCENE_OT_getback(bpy.types.Operator):
return {'FINISHED'}
+class SCENE_OT_savenew(bpy.types.Operator):
+ bl_idname = "save_new_export.pilgway_3d_coat"
+ bl_label = "Export your custom property"
+ bl_description = "Export your custom property"
+ bl_options = {'UNDO'}
+
+ def invoke(self, context, event):
+
+ coat3D = bpy.context.scene.coat3D
+ platform = os.sys.platform
+
+ if(platform == 'win32' or platform == 'darwin'):
+ exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt'
+ else:
+ exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt'
+ if(os.path.isfile(exchangeFile)):
+ folderPath = ''
+
+ if(os.path.isfile(exchangeFile)):
+ file = open(exchangeFile, "w")
+ file.write("%s"%(coat3D.exchangeFolder))
+ file.close()
+
+ return {'FINISHED'}
+
+
class SCENE_OT_folder(bpy.types.Operator):
bl_idname = "update_exchange_folder.pilgway_3d_coat"
bl_label = "Export your custom property"
@@ -267,15 +295,7 @@ class SCENE_OT_folder(bpy.types.Operator):
coat3D = bpy.context.scene.coat3D
if(os.path.isdir(coat3D.exchangeFolder)):
foundExchangeFolder= True
- if(platform == 'win32' or platform == 'darwin'):
- exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + '3DC2Blender'
- else:
- exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + '3DC2Blender'
-
- if(coat3D.exchangeFolder.rfind('Exchange') >= 0):
- file = open(exchangeFile, 'w')
- file.write(coat3D.exchangeFolder)
- file.close()
+ folders.updateExchangeFile(coat3D.exchangeFolder)
return {'FINISHED'}
@@ -1505,6 +1525,7 @@ class SCENE_PT_Settings_Folders(ObjectButtonsPanel, bpy.types.Panel):
col = flow.column()
col.prop(coat3D, "exchangeFolder", text="Exchange folder")
+ col.operator("save_new_export.pilgway_3d_coat", text="Save new Exchange folder")
col = flow.column()
col.prop(coat3D, "defaultfolder", text="Object/Texture folder")
@@ -1926,6 +1947,7 @@ classes = (
SCENE_OT_opencoat,
SCENE_OT_export,
SCENE_OT_getback,
+ SCENE_OT_savenew,
SCENE_OT_delete_material_nodes,
SCENE_OT_delete_object_nodes,
SCENE_OT_delete_collection_nodes,
diff --git a/io_coat3D/folders.py b/io_coat3D/folders.py
index ab143083..ad54bf71 100644
--- a/io_coat3D/folders.py
+++ b/io_coat3D/folders.py
@@ -35,9 +35,9 @@ def InitFolders():
break
folderPath.close()
- if(os.path.isdir(os.path.abspath(savedExchangePath)) and savedExchangePath.rfind('Exchange') >= 0):
- coat3D.exchangeFolder = savedExchangePath
- return True, coat3D.exchangeFolder
+
+ coat3D.exchangeFolder = savedExchangePath
+ return True, coat3D.exchangeFolder
# 2. #################################################################
@@ -94,6 +94,35 @@ def updateExchangeFile(newPath):
file.write("%s"%(newPath))
file.close()
+def loadExchangeFolder():
+
+ platform = os.sys.platform
+ coat3D = bpy.context.scene.coat3D
+
+ if(platform == 'win32' or platform == 'darwin'):
+ DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender'
+ else:
+ DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender'
+
+ exchangeFile = DC2Folder + os.sep + 'Exchange_folder.txt'
+
+ if(not os.path.isdir(DC2Folder)):
+ os.mkdir(DC2Folder)
+
+ if(not os.path.isfile(exchangeFile)):
+ file = open(exchangeFile, 'w')
+ file.close()
+ else:
+ savedExchangePath = ''
+ folderPath = open(exchangeFile)
+
+ for line in folderPath:
+ savedExchangePath = line
+ break
+ folderPath.close()
+ coat3D.exchangeFolder = savedExchangePath
+
+
def set_working_folders():
platform = os.sys.platform