Skip to content

Commit 691d1c7

Browse files
committed
v075 | Added UVchannel preview and switch
- uv channel preview when switch number. this switches uvmap index so we actually can see preview easier
1 parent fac8f85 commit 691d1c7

File tree

3 files changed

+126
-11
lines changed

3 files changed

+126
-11
lines changed

CHANGELOG.md

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

44

5-
## [v0.7.41] - 2024-07-2
5+
## [v0.7.5] - 2024-07-27
6+
# Added
7+
- UVchannel map preview toggle, when switching uv channel. the preview actively changes and also set index of active UVmap
8+
9+
## [v0.7.41] - 2024-07-25
610
# Fixed
711
- missing check for OSX app path set
812

@@ -159,6 +163,7 @@ All notable changes to this project will be documented in this file.
159163
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
160164
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
161165

166+
[v0.7.5]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.5
162167
[v0.7.41]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.41
163168
[v0.7.4]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.4
164169
[v0.7.3]:https://github.com/schroef/uvlayout_bridge/releases/tag/v0.7.3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Headus UVlayout Bridge is a <b>[Blender](https://www.blender.org)</b> add-on for exporting objects from Blender to Headus UVlayout for either quick uvwrapping. Its has multiple options and automation possibilities.
66

7-
![Header Image](https://github.com/schroef/uvlayout_bridge/wiki/images/uvlayout_bridge_v0741.jpg?20240726)
7+
![Header Image](https://github.com/schroef/uvlayout_bridge/wiki/images/uvlayout_bridge_v075.jpg?20240727)
88
>Preview of the Blender Add-on panel Headus UVlayout Bridge
99
1010

__init__.py

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,14 @@
129129
- Dialog operator now uses duplicate of panel by using wm.call_panel > easier and no double code
130130
- Automation is either pack or optimize, running both commands wasnt doing anything since optimize also packs uvs
131131
132-
## [v0.7.41] - 2024-07-2
132+
## [v0.7.41] - 2024-07-25
133133
# Fixed
134134
- missing check for OSX app path set
135135
136+
## [v0.7.5] - 2024-07-25
137+
# Added
138+
- uv channel poreview when switch number. this switches uvmap index so we actually can see preview easier
139+
136140
####################
137141
## TODO
138142
- Seams need to be updated after new import > 0.6.8 still shows old seams
@@ -144,7 +148,7 @@
144148
- Save custom file in dot file next to blend file, now ini file is still per app
145149
- Add better check when UVlayout is canceled, currently it states that all is done
146150
- Autopack sometimes closes without saving on OSX
147-
151+
- When switching UV Channel, make it switch in the panel so we see preview
148152
####################
149153
'''
150154

@@ -153,7 +157,7 @@
153157
"description": "Headus UVLayout Bridge - A bridge between Blender and Headus UVlayout for quick UVs unwrapping",
154158
"location": "3D VIEW > Properties > Headus UVlayout Panel",
155159
"author": "Rombout Versluijs // Titus Lavrov",
156-
"version": (0, 7, 41),
160+
"version": (0, 7, 5),
157161
"blender": (2, 80, 0),
158162
"wiki_url": "https://github.com/schroef/uvlayout_bridge",
159163
"tracker_url": "https://github.com/schroef/uvlayout_bridge/issues",
@@ -210,10 +214,80 @@ def customPath_exists(context):
210214
scn = context.scene
211215
return os.path.exists(scn.uvlb_customPath)
212216

217+
# def object_color_type_items(self,context)
218+
219+
# return colors
220+
221+
def toggle_texture_preview(self,context):
222+
context = bpy.context
223+
scn = context.scene
224+
VIEW3D_PT_shading = bpy.types.VIEW3D_PT_shading
225+
shading = VIEW3D_PT_shading.get_shading(context)
226+
if scn.uvlb_uvPreview == True:
227+
if shading.color_type != 'TEXTURE':
228+
scn.object_color_types = shading.color_type
229+
shading.color_type = 'TEXTURE'
230+
else:
231+
shading.color_type = scn.object_color_types
232+
#toggle actrive UVMAP index
233+
ob = context.active_object
234+
scn=context.scene
235+
ob.data.uv_layers.active_index = scn.uvlb_uv_channel-1
236+
237+
def update_uvchannel_index(self,context):
238+
'''channels uv channel index so we see preview in 3dv when switching'''
239+
# switch uv map index
240+
ob = context.active_object
241+
scn=context.scene
242+
ob.data.uv_layers.active_index = scn.uvlb_uv_channel-1
243+
244+
# set overlay preview
245+
context.scene.uvlb_uvPreview = True
246+
toggle_texture_preview(context, context)
247+
248+
# WIP make it toggle both ways, so if we change index in UVMAPS panel also update int prop
249+
# b3d example GGET/SET
250+
# https://b3d.interplanety.org/en/dynamically-setting-the-max-and-min-values-%E2%80%8B%E2%80%8Bfor-a-custorm-property-in-the-blender-python-api/
251+
def get_uvchannels(self):
252+
uv_channels = bpy.context.active_object.data.uv_layers
253+
# # print(self.get('uvlb_uv_channel'))
254+
# if self.get('uvlb_uv_channel',1) > len(uv_channels)-1:
255+
# print("1")
256+
# return self.get('uvlb_uv_channel')
257+
# elif uv_channels.active_index+1 < self.get('uvlb_uv_channel'):
258+
# print("2")
259+
# return uv_channels.active_index +1
260+
# elif self.get('uvlb_uv_channel',1) < uv_channels.active_index+1:
261+
# print("3")
262+
# return self.get('uvlb_uv_channel')
263+
# else:
264+
# return 1
265+
return self.get('uvlb_uv_channel', 1)
266+
267+
def set_uvchannels(self, value):
268+
uv_channels = bpy.context.active_object.data.uv_layers
269+
if uv_channels:
270+
if value > len(uv_channels):
271+
value = len(uv_channels)
272+
if value < len(uv_channels):
273+
value = 1
274+
else:
275+
value = 1
276+
self['uvlb_uv_channel'] = value
277+
278+
279+
# def get_uvchannels_index(self,context):
280+
# '''Get uv channels active_index'''
281+
# if context.scene and context.active_object:
282+
# ob = context.active_object
283+
# if ob.data.uv_layers != None:
284+
# return ob.data.uv_layers.active_index + 1
285+
286+
287+
#-- LOAD / SET CONFIG FILE --#
213288
configFol = "config"
214289
version = "Please choose version"
215290

216-
#-- LOAD / SET CONFIG FILE --#
217291
def setConfig(self, context):
218292
'''Save Custom Path in config file when property is updated
219293
:param context: context
@@ -318,14 +392,37 @@ def updateIcon(self, context):
318392
update = setConfig)
319393

320394

395+
321396
#-- BRIDGE ADDON OPTIONS --#
322397
#---UV Channel selector---
323398
scn.uvlb_uv_channel = IntProperty(
324399
name = "Map",
325-
description = "Select a UV channel for editing in export.",
400+
description = "Select a UV channel for editing in export. Shows UV channel when setting number for easy preview",
326401
default = 1,
327-
min = 1,
328-
max = 8)
402+
get=get_uvchannels,
403+
set=set_uvchannels,
404+
# get=lambda self: get_uvchannels(self),
405+
# set=lambda self, value: set_uvchannels(self, value),
406+
# min = 1,
407+
# max = get_uvchannels,
408+
update = update_uvchannel_index)
409+
410+
scn.object_color_types = EnumProperty(
411+
items = (('MATERIAL', 'MATERIAL',''),
412+
('OBJECT','OBJECT',''),
413+
('VERTEX','VERTEX',''),
414+
('SINGLE','SINGLE',''),
415+
('RANDOM','RANDOM',''),
416+
('TEXTURE','TEXTURE','')),
417+
name = "Color Type",
418+
description = "Overlayer object Color Type in 3dView",
419+
default = 'MATERIAL')
420+
421+
scn.uvlb_uvPreview = BoolProperty(
422+
name="UV Preview",
423+
description = "Preview UV channel in 3dView, enables texture preview.",
424+
default = False,
425+
update = toggle_texture_preview)
329426

330427
scn.spaceName = BoolProperty(
331428
name="Spaces in Name",
@@ -362,6 +459,12 @@ def updateIcon(self, context):
362459
name = "Mode",
363460
description = "POLY or SUBD",
364461
default = 'EDITMODE_HLT')
462+
scn.iconMode = EnumProperty(
463+
items = (('EDITMODE_HLT', "EDITMODE_HLT", ''),
464+
('MOD_SUBSURF', "MOD_SUBSURF", '')),
465+
name = "Mode",
466+
description = "POLY or SUBD",
467+
default = 'EDITMODE_HLT')
365468

366469
scn.iconUVMode = EnumProperty(
367470
items = (('TEXTURE', "TEXTURE", ''),('GROUP_UVS', "GROUP_UVS", '')),
@@ -1304,9 +1407,16 @@ def draw(self, context):
13041407
layout.use_property_decorate = False # No animation.
13051408
obj = bpy.context.object
13061409

1307-
uvMapBox = layout
1308-
uvMapChannel = uvMapBox.row()
1410+
# uvMapBox = layout
1411+
# uvMapChannel = uvMapBox.split(factor=0.3)
1412+
col = layout.column(align=True)
1413+
uvMapChannel = col.row(align=True)
1414+
if scn.uvlb_uvPreview:
1415+
icon_uv = 'HIDE_OFF'
1416+
else:
1417+
icon_uv = 'HIDE_ON'
13091418
uvMapChannel.prop(scn, "uvlb_uv_channel", icon="GROUP_UVS")
1419+
uvMapChannel.prop(scn, "uvlb_uvPreview", text='', icon=icon_uv)
13101420

13111421
def check_for_mods(scn):
13121422
#--Get selected objects---

0 commit comments

Comments
 (0)