Skip to content

Commit 99f0dc0

Browse files
authored
Option to search for pixologic executable (#521)
* add option to find pixologic zbrush installations * output cleanup --------- Co-authored-by: Daniel Grauer <dg>
1 parent 4b82e72 commit 99f0dc0

File tree

5 files changed

+48
-34
lines changed

5 files changed

+48
-34
lines changed

geometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def remove_internal_faces(obj:Object):
193193
def apply_modifiers(obj:Object) -> Mesh:
194194

195195
if utils.prefs().performance_profiling:
196-
print("\\_____")
196+
print("\\___")
197197
start_time = utils.profiler(time.perf_counter(), f"Export Profiling: {obj.name}")
198198
start_total_time = utils.profiler(time.perf_counter(), "")
199199

gob_export.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -656,17 +656,18 @@ def execute(self, context):
656656
print(e)
657657

658658
# only run if PATH_OBJLIST file file is not empty, else zbrush errors
659-
if not paths.is_file_empty(paths.PATH_OBJLIST) and utils.prefs().export_run_zbrush:
659+
if not paths.is_file_empty(paths.PATH_OBJLIST):
660660
path_exists = paths.find_zbrush(self, context, paths.isMacOS)
661-
if not path_exists:
662-
bpy.ops.gob.search_zbrush('INVOKE_DEFAULT')
663-
else:
664-
if paths.isMacOS:
665-
print("OSX Popen: ", utils.prefs().zbrush_exec)
666-
Popen(['open', '-a', utils.prefs().zbrush_exec, paths.PATH_SCRIPT])
667-
else: #windows
668-
print("Windows Popen: ", utils.prefs().zbrush_exec)
669-
Popen([utils.prefs().zbrush_exec, paths.PATH_SCRIPT], shell=True)
661+
if utils.prefs().export_run_zbrush:
662+
if not path_exists:
663+
bpy.ops.gob.search_zbrush('INVOKE_DEFAULT')
664+
else:
665+
if paths.isMacOS:
666+
print("OSX Popen: ", utils.prefs().zbrush_exec)
667+
Popen(['open', '-a', utils.prefs().zbrush_exec, paths.PATH_SCRIPT])
668+
else: #windows
669+
print("Windows Popen: ", utils.prefs().zbrush_exec)
670+
Popen([utils.prefs().zbrush_exec, paths.PATH_SCRIPT], shell=True)
670671

671672
# restore object context
672673
if context.object and currentContext:

gob_import.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def GoZit(self, pathFile):
110110
unknown_tag = 0
111111
vertsData = []
112112
facesData = []
113+
subdiv = 0
113114
objMat = None
114115
diff_texture, disp_texture, norm_texture = None, None, None
115116
exists = os.path.isfile(pathFile)
@@ -132,31 +133,30 @@ def GoZit(self, pathFile):
132133
print(f"GoB Importing: {objName}")
133134
tag = goz_file.read(4)
134135

136+
135137
while tag:
136138
# Name
137139
if tag == b'\x89\x13\x00\x00':
138140
if utils.prefs().debug_output:
139-
print("__ Name:", tag)
141+
print("_ Name:", tag)
140142
cnt = unpack('<L', goz_file.read(4))[0] - 8
141143
goz_file.seek(cnt, 1)
142144
if utils.prefs().performance_profiling:
143145
start_time = utils.profiler(start_time, "____Unpack Mesh Name")
144146

145-
# This tag 8a13 was introduced with zbrush 2024 and its not clear what it does
146-
# it seems to be a list of some data
147-
# It is not used in the import process and is skipped
148-
elif tag == b'\x8a\x13\x00\x00':
149-
if utils.prefs().debug_output:
150-
print("___ Subdivision Level 8a13:", tag)
147+
# Subdivision Levels
148+
elif tag == b'\x8a\x13\x00\x00':
151149
goz_file.seek(4, 1)
152150
cnt = unpack('<Q', goz_file.read(8))[0]
153-
print('8a13 cnt: ', cnt, range(cnt))
151+
if utils.prefs().debug_output:
152+
print('_ Subdivision Level 8a13 cnt: ', cnt)
153+
print("_ Subdivision Level 8a13:", tag)
154154
for i in range(cnt):
155-
v1 = unpack('<I', goz_file.read(4))[0]
155+
subdiv = unpack('<I', goz_file.read(4))[0]
156156
v2 = unpack('<I', goz_file.read(4))[0]
157157
v3 = unpack('<I', goz_file.read(4))[0]
158158
v4 = unpack('<I', goz_file.read(4))[0]
159-
print('Subdivision Level 8a13: ', v1, v2, v3, v4)
159+
print('_ _ Subdivision Level 8a13: ', subdiv, v2, v3, v4)
160160

161161
# Vertices
162162
elif tag == b'\x11\x27\x00\x00':
@@ -240,13 +240,13 @@ def GoZit(self, pathFile):
240240
start_time = utils.profiler(start_time, "Make Mesh \n")
241241

242242
unknown_tag = 0
243-
while tag:
244243

244+
245+
while tag:
245246
# UVs
246247
if tag == b'\xa9\x61\x00\x00':
247248
if utils.prefs().debug_output:
248-
print("Import UV: ", utils.prefs().import_uv)
249-
249+
print("Import UV: ", utils.prefs().import_uv)
250250

251251
goz_file.seek(4, 1) # Always skip the header
252252
cnt = unpack('<Q', goz_file.read(8))[0] # Read the face count
@@ -293,7 +293,6 @@ def GoZit(self, pathFile):
293293
# Each face has 4 UV coordinates, so multiply by 4
294294
goz_file.seek(cnt * 4 * 8, 1) # Skip the UV weights
295295

296-
297296
# Polypainting
298297
elif tag == b'\xb9\x88\x00\x00':
299298
if utils.prefs().debug_output:
@@ -311,7 +310,7 @@ def GoZit(self, pathFile):
311310
vertex_data = goz_file.read(3)
312311
if len(vertex_data) < 3:
313312
if utils.prefs().debug_output:
314-
print("error if buffer length is less than 3: ", i, vertex_data)
313+
print("error if buffer length is less than 3: ", i, cnt, vertex_data)
315314
break
316315

317316
colordata = unpack('<3B', vertex_data) # Color
@@ -360,7 +359,7 @@ def GoZit(self, pathFile):
360359
vertex_data = goz_file.read(3)
361360
if len(vertex_data) < 3:
362361
if utils.prefs().debug_output:
363-
print(f"Error: Buffer length less than 3 at index {i}: {vertex_data}")
362+
print(f"Error: Buffer length less than 3 at index {i} {cnt}: {vertex_data}")
364363
break
365364
colordata = unpack('<3B', vertex_data) # Color
366365
goz_file.seek(1, 1) # Skip Alpha byte
@@ -379,7 +378,6 @@ def GoZit(self, pathFile):
379378
# Skip over the polypaint data if not importing
380379
goz_file.seek(cnt * 4, 1) # Skip the polypaint weights
381380

382-
383381
# Mask
384382
elif tag == b'\x32\x75\x00\x00':
385383
if utils.prefs().debug_output:

paths.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,18 @@ def find_zbrush(self, context, isMacOS):
108108
ui.ShowReport(self, [utils.prefs().zbrush_exec], "GoB: Zbrush default installation found", 'COLORSET_03_VEC')
109109
self.is_found = True
110110
else:
111-
# Look for ZBrush in default installation paths
112-
default_paths = [
113-
os.path.join("C:\\", "Program Files"),
114-
os.path.join("C:\\", "Program Files", "Pixologic")
115-
]
111+
# Determine the base paths based on the preference setting
112+
if utils.prefs().use_pixologic_path:
113+
default_paths = [os.path.join("C:\\", "Program Files", "Pixologic")]
114+
else:
115+
default_paths = [os.path.join("C:\\", "Program Files")]
116+
117+
# Check if the default paths exist and search for ZBrush folders
116118
for base_path in default_paths:
117119
if not os.path.isdir(base_path):
118120
continue
119-
121+
122+
# Check for ZBrush folders in the base path
120123
folder_list = [folder for folder in os.listdir(base_path) if 'zbrush' in str.lower(folder)]
121124
if not folder_list:
122125
continue

preferences.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class GoB_Preferences(AddonPreferences):
4949
"\nIf not specified the system default for Zscript (.zsc) files will be used",
5050
subtype='FILE_PATH',
5151
default="") # Default: ""
52+
53+
use_pixologic_path: BoolProperty(
54+
name="Find Pixologic Version",
55+
description="When enabled the addon will search for the Pixologic ZBrush executable over the Maxon executable, "
56+
"\nthis is useful if you have a Pixologic installation of ZBrush and want to use it with GoB. "
57+
"\nIf you have a Maxon installation of ZBrush, please disable this option",
58+
default=False) # Default: False
5259

5360
custom_pixologoc_path: BoolProperty(
5461
name="Custom Pixologic Public Path",
@@ -250,6 +257,10 @@ class GoB_Preferences(AddonPreferences):
250257
import_uv_flip_x: BoolProperty(name='UV Map Flip X', default=False) # Default: False
251258
import_uv_flip_y: BoolProperty(name='UV Map Flip Y', default=True) # Default: True
252259

260+
import_subdiv: BoolProperty(
261+
name="Subdiv",
262+
description="Import Subdivision Levels",
263+
default=True) # Default: True
253264

254265
import_polypaint: BoolProperty(
255266
name="Polypaint",
@@ -323,6 +334,7 @@ def draw_options(self, box):
323334
box.use_property_split = True
324335
box.label(text='GoB General Options', icon='PREFERENCES')
325336
col = box.column(align=False)
337+
col.prop(self, 'use_pixologic_path')
326338
col.prop(self, 'zbrush_exec')
327339
col.prop(self, 'project_path')
328340

0 commit comments

Comments
 (0)