Skip to content

Commit 92868ee

Browse files
committed
v073 -| Fixed issue with GUI when appPath is not set
Now panel is hidden and red choose appPath option is shown.
1 parent e8a70e9 commit 92868ee

File tree

7 files changed

+101
-69
lines changed

7 files changed

+101
-69
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33

44

5+
## [v0.7.3] - 2024-07-24
6+
7+
# Fixed
8+
- Export error if app path is not set, Panel shows red error with set app path option
9+
510
## [v0.7.2] - 2024-07-23
611

712
# Fixed
@@ -141,6 +146,7 @@ All notable changes to this project will be documented in this file.
141146
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
142147
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
143148

149+
[v0.7.3]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.3
144150
[v0.7.2]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.2
145151
[v0.7.1]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.1
146152
[v0.6.5]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.6.5_2.80

__init__.py

Lines changed: 94 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# - Try scene without getConfig this is not needed as enum already loads settings
99
# - Added d2.80 support
1010
# - updated user_preferences to preferences
11+
# - Add warning when appPath is not set
1112
####################
1213
1314
####################
@@ -100,25 +101,20 @@
100101
# Changed
101102
- Better check if we cancel or send file back to Blender > returns cancel or done report in bottom
102103
103-
## v.0.7.1
104-
## 2021-11-10
104+
## v.0.7.1 - 2021-11-10
105105
106106
# Changed
107107
- get path and files moved to its own function, same code was used 6 times
108108
109-
## v.0.7.2
110-
## 2024-07-23
109+
## v.0.7.2 - 2024-07-23
111110
112111
# Fixed
113112
- Changed parameter for OBJ importer and exporter.
114113
115-
# Added
116-
- check for different Blender versions, they use different operators and parameters
117-
- Show alert for when custom path does not exist, path turns red
114+
## v.0.7.3 - 2024-07-24
118115
119-
# Changed
120-
- info custom path is added to tooltip
121-
- Removed Local check, seems to be working now without issues perhaps due to new viewlayer system
116+
# Fixed
117+
- Export error if app path is not set, Panel shows red error with set app path option
122118
123119
124120
####################
@@ -141,7 +137,7 @@
141137
"description": "Headus UVLayout Bridge - A bridge between Blender and Headus UVlayout for quick UVs unwrapping",
142138
"location": "3D VIEW > Properties > Headus UVlayout Panel",
143139
"author": "Rombout Versluijs // Titus Lavrov",
144-
"version": (0, 7, 2),
140+
"version": (0, 7, 3),
145141
"blender": (2, 80, 0),
146142
"wiki_url": "https://github.com/schroef/uvlayout_bridge",
147143
"tracker_url": "https://github.com/schroef/uvlayout_bridge/issues",
@@ -167,6 +163,34 @@
167163
from bpy_extras.io_utils import (ImportHelper, ExportHelper)
168164
from . config.registers import get_hotkey_entry_item
169165

166+
#---Check OS---
167+
# bpy.types.Scene.osSys = EnumProperty(
168+
# items = (('0', "WIN", ''),('1', "OSX", '')),
169+
# name = "OS check",
170+
# description="Check what OS is used",
171+
# default = '0')
172+
#--SYS check Enummenus --#
173+
scn = bpy.types.Scene
174+
if platform == "darwin":
175+
scn.osSys = '1'
176+
if platform == "win32":
177+
scn.osSys = '0'
178+
print("OS used: %s" % platform)
179+
180+
181+
182+
# return addon preferences
183+
def get_addon_prefs(context):
184+
return context.preferences.addons[__name__].preferences
185+
186+
187+
def app_path_set(context):
188+
addon_prefs = get_addon_prefs(context)
189+
if platform == "win32":
190+
return addon_prefs.uvlb_winPath != 'Please set Application Path'
191+
if platform == "darwin":
192+
return addon_prefs.versionUVL != 'Please choose version'
193+
170194
configFol = "config"
171195
version = "Please choose version"
172196

@@ -405,20 +429,6 @@ def updateIcon(self, context):
405429
default = False,
406430
description="Forces reimport of the out file from UVlayout. Sometimes import mismatches timing of UVlayout causing to not import proper output file.")
407431

408-
#---Check OS---
409-
# bpy.types.Scene.osSys = EnumProperty(
410-
# items = (('0', "WIN", ''),('1', "OSX", '')),
411-
# name = "OS check",
412-
# description="Check what OS is used",
413-
# default = '0')
414-
#--SYS check Enummenus --#
415-
scn = bpy.types.Scene
416-
if platform == "darwin":
417-
scn.osSys = '1'
418-
if platform == "win32":
419-
scn.osSys = '0'
420-
print("OS used: %s" % platform)
421-
422432

423433
def is_local(context):
424434
#for ob in bpy.context.scene.objects:
@@ -822,7 +832,7 @@ def add_obj(obj):
822832
if dropSet == 0:
823833
# loadAction = 'run UVLayout|Pack|Pack All' + '\n' +'run UVLayout|Plugin|Save'
824834
# loadAction = "drop \ n auto obj \n auto dxf "
825-
loadAction = uvlb_mode + uvlb_uv_mode + uvlb_uv_weld + uvlb_uv_clean + uvlb_uv_deach + uvlb_uv_geom
835+
loadAction = uvlb_mode + uvlb_uv_mode + uvlb_uv_weld + uvlb_uv_clean + uvlb_uv_deach + uvlb_uv_geom
826836

827837
f = open(file_setName, "w+")
828838
# print("Commands Sent: %s - %s" % (uvlb_mode, uvlb_uv_mode))
@@ -1223,16 +1233,22 @@ def draw(self, context):
12231233
layout = self.layout
12241234
scn = bpy.context.scene
12251235
obj = bpy.context.object
1236+
addon_prefs = get_addon_prefs(context)
1237+
1238+
if platform == "win32" and (addon_prefs.uvlb_winPath == 'Please set Application Path'):
1239+
layout.alert = addon_prefs.uvlb_winPath == 'Please set Application Path'
1240+
layout.label(text = "Application Path Headus UVLayout v2.")
1241+
layout.prop(addon_prefs, "uvlb_winPath", text="")
12261242

12271243

12281244
class VIEW3D_PT_load_options(UVLBRIDGE, Panel):
12291245
bl_label = "Load Options"
12301246
bl_parent_id = "VIEW3D_PT_panel_uvlbridge"
12311247

1232-
# @classmethod
1233-
# def poll(cls, context):
1234-
# # Only allow in Object mode and for a selected mesh.
1235-
# return (context.object is not None and context.object.type == "MESH")
1248+
@classmethod
1249+
def poll(cls, context):
1250+
# print(app_path_set(context))
1251+
return app_path_set(context)
12361252

12371253
def draw(self, context):
12381254
layout = self.layout
@@ -1244,11 +1260,12 @@ def draw(self, context):
12441260
settingsBox = layout
12451261
uvlbHeader = settingsBox.split(factor=0.9)
12461262
column = uvlbHeader.column()
1263+
12471264
# column.row().label(text="Load Options:")
12481265

12491266
# column = uvlbHeader.column()
12501267
# column.row().prop(scn, "uvlb_help", text="", icon_value=custom_icons["help"].icon_id, emboss=False)
1251-
1268+
12521269
uvlbOptions = settingsBox.split(factor=0.5)
12531270
column = uvlbOptions.column()
12541271
column.row().label(text="Mode:")
@@ -1278,6 +1295,10 @@ class VIEW3D_PT_automation(UVLBRIDGE, Panel):
12781295
bl_label = " Automation"
12791296
bl_parent_id = "VIEW3D_PT_panel_uvlbridge"
12801297

1298+
@classmethod
1299+
def poll(cls, context):
1300+
return app_path_set(context)
1301+
12811302
def draw_header(self, context):
12821303
layout = self.layout
12831304
scn = bpy.context.scene
@@ -1316,7 +1337,7 @@ class VIEW3D_PT_uvchannel(UVLBRIDGE, Panel):
13161337
@classmethod
13171338
def poll(cls, context):
13181339
scn = bpy.context.scene
1319-
return check_uv_channels(scn)
1340+
return check_uv_channels(scn) and app_path_set(context)
13201341

13211342
def draw(self, context):
13221343
layout = self.layout
@@ -1352,6 +1373,10 @@ class VIEW3D_PT_export_options(UVLBRIDGE, Panel):
13521373
bl_label = "OBJ Eport Options"
13531374
bl_parent_id = "VIEW3D_PT_panel_uvlbridge"
13541375

1376+
@classmethod
1377+
def poll(cls, context):
1378+
return app_path_set(context)
1379+
13551380
def draw(self, context):
13561381
layout = self.layout
13571382
scn = bpy.context.scene
@@ -1398,43 +1423,44 @@ def draw(self, context):
13981423

13991424

14001425
def uvl_panel_operator(self,context):
1401-
layout = self.layout
1402-
#-- START EXPORT --
1403-
layout.scale_y = 1.25
1404-
# row = layout.row(align=True)
1405-
# col = row.column(align=True)
1406-
col = layout.column(align=True)
1407-
row = col.row(align=True)
1408-
row.operator("uvlb.export", text = "Unwrap in UVlayout", icon_value=custom_icons["uvl"].icon_id)
1409-
row.operator("uvlb.send_tmpedit", text = "", icon='FILE_TICK') # TEMP RECOVER_LAST LOOP_BACK
1410-
1411-
scn,addon_prefs, UVLayoutPath, file_Name,file_outName, file_setName, file_cmdName, uvl_exit_str, uvlObjs, Objs = get_path_files()
1412-
# Make this cleaner > this section is used 3x > make single functon
1413-
# preferences = bpy.context.preferences
1414-
# addon_prefs = preferences.addons[__name__].preferences
1415-
# scn = bpy.context.scene
1426+
if app_path_set(context):
1427+
layout = self.layout
1428+
#-- START EXPORT --
1429+
layout.scale_y = 1.25
1430+
# row = layout.row(align=True)
1431+
# col = row.column(align=True)
1432+
col = layout.column(align=True)
1433+
row = col.row(align=True)
1434+
row.operator("uvlb.export", text = "Unwrap in UVlayout", icon_value=custom_icons["uvl"].icon_id)
1435+
row.operator("uvlb.send_tmpedit", text = "", icon='FILE_TICK') # TEMP RECOVER_LAST LOOP_BACK
1436+
1437+
scn,addon_prefs, UVLayoutPath, file_Name,file_outName, file_setName, file_cmdName, uvl_exit_str, uvlObjs, Objs = get_path_files()
1438+
# Make this cleaner > this section is used 3x > make single functon
1439+
# preferences = bpy.context.preferences
1440+
# addon_prefs = preferences.addons[__name__].preferences
1441+
# scn = bpy.context.scene
14161442

1417-
# #---Variables---
1418-
# if platform == "win32":
1419-
# UVLayoutPath = addon_prefs.uvlb_winPath
1443+
# #---Variables---
1444+
# if platform == "win32":
1445+
# UVLayoutPath = addon_prefs.uvlb_winPath
14201446

1421-
# if scn.uvlb_pathEnable:
1422-
# path = scn.uvlb_customPath
1423-
# else:
1424-
# path = "" + tempfile.gettempdir()
1447+
# if scn.uvlb_pathEnable:
1448+
# path = scn.uvlb_customPath
1449+
# else:
1450+
# path = "" + tempfile.gettempdir()
14251451

1426-
# path = '/'.join(path.split('\\'))
1452+
# path = '/'.join(path.split('\\'))
14271453

1428-
# file_outName = path + "Blender2UVLayout_TMP.out"
1429-
1430-
# print(os.path.isfile(file_outName))
1431-
# print(os.path.exists(file_outName))
1432-
# print(file_outName)
1433-
###################
1434-
if os.path.exists(file_outName):
1435-
# if os.path.isfile(file_outName):
1436-
row = col.row(align=True)
1437-
row.operator("uvlb.forced_reimport", icon='RECOVER_LAST') # RECOVER_LAST LOOP_BACK
1454+
# file_outName = path + "Blender2UVLayout_TMP.out"
1455+
1456+
# print(os.path.isfile(file_outName))
1457+
# print(os.path.exists(file_outName))
1458+
# print(file_outName)
1459+
###################
1460+
if os.path.exists(file_outName):
1461+
# if os.path.isfile(file_outName):
1462+
row = col.row(align=True)
1463+
row.operator("uvlb.forced_reimport", icon='RECOVER_LAST') # RECOVER_LAST LOOP_BACK
14381464

14391465

14401466
#-- BRIDGE WM DIALOG POPUP MENU __#
@@ -1454,7 +1480,7 @@ def check(self, context):
14541480
@classmethod
14551481
def poll(cls, context):
14561482
# Only allow in Object mode and for a selected mesh.
1457-
return (bpy.context.object is not None and bpy.context.object.type == "MESH")
1483+
return (bpy.context.object is not None and bpy.context.object.type == "MESH") and not app_path_set(context)
14581484

14591485
def draw(self, context):
14601486
layout = self.layout
@@ -1645,18 +1671,19 @@ def draw(self, context):
16451671
layout = self.layout
16461672
scene = context.scene
16471673

1648-
16491674
if platform == "win32":
16501675
box=layout.box()
16511676
split = box.split()
16521677
col = split.column()
1678+
col.alert = (self.uvlb_winPath == 'Please set Application Path')
16531679
col.label(text = "Application Path Headus UVLayout v2.")
16541680
col.prop(self, "uvlb_winPath", text="")
16551681
col.separator()
16561682
if platform == "darwin":
16571683
box=layout.box()
16581684
split = box.split()
16591685
col = split.column()
1686+
col.alert = (self.versionUVL == 'Please choose version')
16601687
col.label(text = "Headus UVlayout Version:")
16611688
col.prop(self,"versionUVL", text="")
16621689
col.label(text = "* No application path settings needed on OSX")
@@ -1671,7 +1698,6 @@ def draw(self, context):
16711698
column.row().label(text = "Custom export path:")
16721699
if scene.uvlb_pathEnable:
16731700
row = column.row()
1674-
# Not sure why but got error here for not being string?
16751701
row.alert = not os.path.exists(scene.uvlb_customPath)
16761702
row.prop(scene,"uvlb_customPath", text="")
16771703

631 Bytes
Binary file not shown.
1012 Bytes
Binary file not shown.
607 Bytes
Binary file not shown.
623 Bytes
Binary file not shown.

config/config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[main]
2-
version = pro
2+
version = Please choose version
33
custompath = Please set path
44
pathenable = False
55
winpath = Please set path

0 commit comments

Comments
 (0)