4
$\begingroup$

I would like to create a shortcut for changing a solidify modifiers thickness much like changing the amount of subdivision with Ctrl + number or hitting the S key and typing the number for scaling. Is there an easy way to do that?

$\endgroup$

1 Answer 1

6
+50
$\begingroup$

This can be easily done with python.

1. Get the script

Copy the script into blender's text editor and save it as "solidify_set.py" (NOT "solidify_set.py.txt").

OR

Download from github (see the comments for more info).

2. Install it as an add-on

(make sure to click the all category and the community supported level)

3. Add the hotkeys that you would like

It should be added in the "3D View > Object Mode" section where the subdivision set operator is.

enter image description here

Click Add New, then enter "solidify_raise", then enter your hotkey (and select any key modifiers you want...shift, ctrl, etc.). Click Add New, then enter "solidify_lower", then enter your hotkey (and select any key modifiers you want...shift, ctrl, etc.). You can click on the amount setting to set the amount it shifts. Clicking on the restore button, restores your hotkeys to the way they were before. Finally, don't forget to save user prefs with Save User Settings :-)

enter image description here

# Copyright 2016 Jake Dube
#
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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
# MERCHANTABILITY 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/>.
#
# ##### END GPL LICENSE BLOCK #####

import bpy
from bpy.types import Operator
from bpy.props import FloatProperty

bl_info = {
    "name": "Solidify Set",
    "author": "Jake Dube",
    "version": (1, 0),
    "blender": (2, 77, 0),
    "location": "Spacebar > Solidify Raise/Lower",
    "category": "Object",
}

class RaiseSolidify(Operator):
    """Raises solidify modifier."""
    bl_idname = "object.solidify_raise"
    bl_label = "Solidify Raise"
    bl_options = {"REGISTER", "UNDO"}

    amount = FloatProperty(name="Amount", default=0.01)

    def draw(self, context):
        layout = self.layout
        layout.prop(self, 'amount')

    def execute(self, context):
        scene = bpy.context.scene
        for obj in bpy.context.selected_objects:
            scene.objects.active = obj
            modifiers = obj.modifiers
            found = False
            for mod in modifiers:
                if mod.type == 'SOLIDIFY':
                    mod.thickness += self.amount
                    found = True
                    break
            if not found:
                bpy.ops.object.modifier_add(type='SOLIDIFY')
                for mod in modifiers:
                    if mod.type == 'SOLIDIFY':
                        mod.thickness += self.amount
        return {'FINISHED'}


class LowerSolidify(Operator):
    """Lowers solidify modifier."""
    bl_idname = "object.solidify_lower"
    bl_label = "Solidify Lower"
    bl_options = {"REGISTER", "UNDO"}

    amount = FloatProperty(name="Amount", default=0.01)

    def draw(self, context):
        layout = self.layout
        layout.prop(self, 'amount')

    def execute(self, context):
        scene = bpy.context.scene
        for obj in bpy.context.selected_objects:
            scene.objects.active = obj
            modifiers = obj.modifiers
            found = False
            for mod in modifiers:
                if mod.type == 'SOLIDIFY':
                    mod.thickness -= self.amount
                    found = True
                    break
            if not found:
                bpy.ops.object.modifier_add(type='SOLIDIFY')
                for mod in modifiers:
                    if mod.type == 'SOLIDIFY':
                        mod.thickness -= self.amount
        return {'FINISHED'}


def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == '__main__':
    register()

enter image description here

Troubleshooting add-on installation tips:

$\endgroup$
14
  • 1
    $\begingroup$ I thought about doing built-in key mapping, but when you consider the vast number of add-ons available (that many people have installed) there would be too many conflicts. Other problems: you don't even have the key that I would have used, there are problems with laptops that don't have numpads (like the one I am typing this with :-), and there are differences between mac and windows keyboards as well. That's why I think it's easiest to just set it up manually in the user prefs. On the other hand, if it is built from script, it could always be changed later if it did cause a conflict... $\endgroup$
    – JakeD
    Commented Sep 5, 2016 at 11:30
  • $\begingroup$ Thank you, @pycoder, but I can't import your script as an addon. If I try to, Blender just shows me the default addon screen. Which Blender Version did you use? I am currently using Blender 2.77. $\endgroup$ Commented Sep 5, 2016 at 13:36
  • $\begingroup$ @schustudrai Did you save it as a .py file? Did you copy the entire script? $\endgroup$
    – JakeD
    Commented Sep 5, 2016 at 14:29
  • $\begingroup$ @schustudrai Did you click the "all" category and the "community" supported level? $\endgroup$
    – JakeD
    Commented Sep 6, 2016 at 11:12
  • $\begingroup$ I have saved the whole script as a .py file @pycoder. I also tried clicking the all and community support level. "Solidify Set" still does not show up. $\endgroup$ Commented Sep 6, 2016 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .