blenderings/retopo_tools/__init__.py

82 lines
2.6 KiB
Python
Raw Normal View History

2022-12-22 13:35:06 -07:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import bpy
from bpy.types import Context
bl_info = {
"name" : "RetopoTools",
"author" : "Name",
"description" : "Set up a standard retopology workflow for a selected object, if 2 objects are selected, then the non-active object is used as the target of mirror and shrinkwrap",
"blender" : (2, 80, 0),
"version" : (0, 0, 1),
"location" : "",
"warning" : "",
"category" : "Generic"
}
from .tool import RetopoProjectModeOperator, RetopoVertexModeOperator
def RetopoProjectModeOperator_menu_func(self, context: Context):
return self.layout.operator(RetopoProjectModeOperator.bl_idname)
def RetopoVertexModeOperator_menu_func(self, context: Context):
return self.layout.operator(RetopoVertexModeOperator.bl_idname)
from . import auto_load
auto_load.init()
addon_keymaps = []
def register_keymaps():
addon_kc = bpy.context.window_manager.keyconfigs.addon
if addon_kc is None:
return
for mode in ("Window",):
km = addon_kc.keymaps.new(name=mode)
kmis = tuple(
km.keymap_items.new(
Operator.bl_idname,
type="NONE",
value="ANY",
)
for Operator in (RetopoProjectModeOperator, RetopoVertexModeOperator)
)
addon_keymaps.append((km, kmis))
def unregister_keymaps():
# Don't know if this is really neccessary but this is what they do in the docs tutorial...
for km, kmis in addon_keymaps:
for kmi in kmis:
km.keymap_items.remove(kmi)
bpy.context.window_manager.keyconfigs.addon.keymaps.remove(km)
addon_keymaps.clear()
def register():
auto_load.register()
bpy.types.VIEW3D_MT_object.append(RetopoProjectModeOperator_menu_func)
bpy.types.VIEW3D_MT_object.append(RetopoVertexModeOperator_menu_func)
register_keymaps()
def unregister():
auto_load.unregister()
bpy.types.VIEW3D_MT_object.remove(RetopoProjectModeOperator_menu_func)
bpy.types.VIEW3D_MT_object.remove(RetopoVertexModeOperator_menu_func)
unregister_keymaps()