fix some name error and add no uv checker

This commit is contained in:
yyc12345 2020-08-31 21:56:08 +08:00
parent 97659f74cc
commit 751ff15b95
4 changed files with 62 additions and 24 deletions

View File

@ -18,17 +18,19 @@ if "bpy" in locals():
import importlib import importlib
if "bm_import_export" in locals(): if "bm_import_export" in locals():
importlib.reload(bm_import_export) importlib.reload(bm_import_export)
if "floor_rail_uv" in locals(): if "rail_uv" in locals():
importlib.reload(floor_rail_uv) importlib.reload(rail_uv)
if "utils" in locals(): if "utils" in locals():
importlib.reload(utils) importlib.reload(utils)
if "config" in locals(): if "config" in locals():
importlib.reload(config) importlib.reload(config)
if "preferences" in locals(): if "preferences" in locals():
importlib.reload(preferences) importlib.reload(preferences)
if "super_align" in locals(): if "threedsmax_align" in locals():
importlib.reload(super_align) importlib.reload(threedsmax_align)
from . import config, utils, bm_import_export, floor_rail_uv, preferences, super_align if "no_uv_checker" in locals():
importlib.reload(no_uv_checker)
from . import config, utils, bm_import_export, rail_uv, preferences, threedsmax_align, no_uv_checker
# ============================================= menu system # ============================================= menu system
@ -40,8 +42,9 @@ class ThreeDViewerMenu(bpy.types.Menu):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.operator("ballance.super_align") layout.operator("ballance.threedsmax_align")
layout.operator("ballance.rail_uv") layout.operator("ballance.rail_uv")
layout.operator("ballance.no_uv_checker")
# ============================================= blender call system # ============================================= blender call system
@ -49,8 +52,9 @@ classes = (
preferences.BallanceBlenderPluginPreferences, preferences.BallanceBlenderPluginPreferences,
bm_import_export.ImportBM, bm_import_export.ImportBM,
bm_import_export.ExportBM, bm_import_export.ExportBM,
floor_rail_uv.RailUVOperator, rail_uv.RailUVOperator,
super_align.SuperAlignOperator, threedsmax_align.SuperAlignOperator,
no_uv_checker.NoUVCheckerOperator,
ThreeDViewerMenu ThreeDViewerMenu
) )

View File

@ -0,0 +1,45 @@
import bpy,bmesh
from . import utils
class NoUVCheckerOperator(bpy.types.Operator):
"""Check whether the currently selected object has UV"""
bl_idname = "ballance.no_uv_checker"
bl_label = "Check UV"
bl_options = {'UNDO'}
@classmethod
def poll(self, context):
return check_valid_target()
def execute(self, context):
check_target()
return {'FINISHED'}
# ====================== method
def check_valid_target():
return (len(bpy.context.selected_objects) > 0)
def check_target():
noUVObject = []
invalidObjectCount = 0
for obj in bpy.context.selected_objects:
if obj.type != 'MESH':
invalidObjectCount+=1
continue
if obj.mode != 'OBJECT':
invalidObjectCount+=1
continue
if obj.data.uv_layers.active is None:
noUVObject.append(obj.name)
result = ("All objects: {}, Skipped: {}, No UV Count: {}. Following object don't have UV: ".format(len(bpy.context.selected_objects), invalidObjectCount, len(noUVObject)) +
", ".join(noUVObject[:4]) +
(". Too much objects don't have UV. Please open terminal to browse them." if len(noUVObject) > 4 else ""))
if len(noUVObject) > 4:
print("Following object don't have UV:")
for item in noUVObject:
print(item)
utils.ShowMessageBox(result, "Check result", 'INFO')

View File

@ -23,7 +23,7 @@ def check_rail_target():
continue continue
if obj.mode != 'OBJECT': if obj.mode != 'OBJECT':
continue continue
if obj.data.uv_layers.active.data == None: if obj.data.uv_layers.active is None:
continue continue
return True return True
return False return False
@ -38,7 +38,7 @@ def create_rail_uv():
if obj.mode != 'OBJECT': if obj.mode != 'OBJECT':
ignoredObj.append(obj.name) ignoredObj.append(obj.name)
continue continue
if obj.data.uv_layers.active.data == None: if obj.data.uv_layers.active is None:
ignoredObj.append(obj.name) ignoredObj.append(obj.name)
continue continue
@ -54,15 +54,4 @@ def create_rail_uv():
uv_layer[loop_index].uv[1] = 1 # vecList[index].co[1] uv_layer[loop_index].uv[1] = 1 # vecList[index].co[1]
if len(ignoredObj) != 0: if len(ignoredObj) != 0:
utils.ShowMessageBox("Following objects are not processed due to they are not suit for this function now: " + ', '.join(ignoredObj), "No processed object", 'WARNING') utils.ShowMessageBox("Following objects are not processed due to they are not suit for this function now: " + ', '.join(ignoredObj), "Check result", 'INFO')
def virtoolize_floor_uv():
pass
def mesh_triangulate(me):
bm = bmesh.new()
bm.from_mesh(me)
bmesh.ops.triangulate(bm, faces=bm.faces)
bm.to_mesh(me)
bm.free()

View File

@ -3,8 +3,8 @@ from . import utils
class SuperAlignOperator(bpy.types.Operator): class SuperAlignOperator(bpy.types.Operator):
"""Align object with 3ds Max way""" """Align object with 3ds Max way"""
bl_idname = "ballance.super_align" bl_idname = "ballance.threedsmax_align"
bl_label = "Super Align" bl_label = "3ds Max Align"
bl_options = {'UNDO'} bl_options = {'UNDO'}
align_x: bpy.props.BoolProperty(name="X position") align_x: bpy.props.BoolProperty(name="X position")