Created
February 26, 2021 01:11
-
-
Save suchmememanyskill/94b41d9f479aa7570825eb314375f456 to your computer and use it in GitHub Desktop.
Blender text solidify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Warning. Shit code ahead | |
| # Solidify text using Control + T | |
| bl_info = { | |
| "name": "Text Solidify", | |
| "blender": (2, 80, 0), | |
| "category": "Object", | |
| } | |
| import bpy | |
| class TextSolidify(bpy.types.Operator): | |
| """Text Solidify""" | |
| bl_idname = "object.text_solidify" | |
| bl_label = "Text solidify" | |
| bl_options = {'REGISTER', 'UNDO'} | |
| thickness: bpy.props.FloatProperty(name="Thickness", default=1, min=-10, max=10) | |
| def execute(self, context): | |
| scene = context.scene | |
| obj = context.active_object | |
| objType = getattr(obj, 'type', '') | |
| print(objType) | |
| if (objType == "FONT"): | |
| bpy.ops.object.convert(target='MESH', keep_original=False) | |
| bpy.ops.object.modifier_add(type='DECIMATE') | |
| bpy.context.object.modifiers["Decimate"].ratio = 0.8 | |
| bpy.ops.object.modifier_apply(modifier="Decimate") | |
| bpy.ops.object.modifier_add(type='SOLIDIFY') | |
| bpy.context.object.modifiers["Solidify"].thickness = self.thickness | |
| return {'FINISHED'} | |
| def menu_func(self, context): | |
| self.layout.operator(TextSolidify.bl_idname) | |
| addon_keymaps = [] | |
| def register(): | |
| bpy.utils.register_class(TextSolidify) | |
| bpy.types.VIEW3D_MT_object.append(menu_func) | |
| # handle the keymap | |
| wm = bpy.context.window_manager | |
| kc = wm.keyconfigs.addon | |
| if kc: | |
| km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY') | |
| kmi = km.keymap_items.new(TextSolidify.bl_idname, 'T', 'PRESS', ctrl=True) | |
| addon_keymaps.append((km, kmi)) | |
| def unregister(): | |
| for km, kmi in addon_keymaps: | |
| km.keymap_items.remove(kmi) | |
| addon_keymaps.clear() | |
| bpy.utils.unregister_class(TextSolidify) | |
| bpy.types.VIEW3D_MT_object.remove(menu_func) | |
| if __name__ == "__main__": | |
| register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment