[Request] Number Box for changing octree depth in Nicholas Dynamic-topology Script

Hi,

some Time Ago, Nicholas Bishop released a very useful Script, that allows to remesh the Topology of a Mesh in Sculpt Mode, with a single Shortcut (The Script simply add and apply a Remesh-Modifier). This is very useful for Sculpting without the need to model a Base Mesh (close to ZB Dynamesh).

But the current Version has a big Limitation: The octree depth (Level of topology detail) is hardcodes inside the Script.

I like to start with a low octree depth for Sculpting the general shape, and then start to sculpt in details as much as i can with the next octree depth step, and so on (The workflow is similar to working with different detail Levels with the Multires Modifier.

My current Workfow is to sculpt as much as i can with the current octree depth level, then

  • save the blend
  • close Blender
  • open the Script File
  • change the octree depth
  • save the Script File
  • open blender
  • reload the blend file
    Every time i need to use a different octree depth level.

I would really love to have some sort of a Number input Box in the Sculpt Menu on the left side, where i can change the octree depth level. Is there a Blender Dev. who like to make this happen?

Script Relase: https://plus.google.com/115590915811047740045/posts/bn6QXZXQkCF
Source Code: http://nicholasbishop.net/random/sculpt-remesh.py

Put this together as a menu then reread your post. Here is code to make it a menu\



import bpy
from bpy.props import IntProperty
class RemeshOperator(bpy.types.Operator):
    '''Tooltip'''
    bl_idname = "sculpt.remesh"
    bl_label = "Sculpt Remesh"
    octree_depth = IntProperty(default=5)

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        # add a smooth remesh modifier
        ob = context.active_object
        md = ob.modifiers.new('sculptremesh', 'REMESH')
        md.mode = 'SMOOTH'
        md.octree_depth = self.octree_depth

        # apply the modifier
        bpy.ops.object.modifier_apply(apply_as='DATA', modifier="sculptremesh")
        
        return {'FINISHED'}

class SimpleCustomMenu(bpy.types.Menu):
    bl_label = "Simple Custom Menu"
    bl_idname = "OBJECT_MT_simple_custom_menu"
    depths = [2,3,5,8]
    
    def draw(self, context):
        layout = self.layout
        for depth in self.depths:
            layout.operator("sculpt.remesh", text="Sculpt OT=%d" % depth).octree_depth = depth
                
def register():
    bpy.utils.register_class(RemeshOperator)
    bpy.utils.register_class(SimpleCustomMenu)


def unregister():
    bpy.utils.unregister_class(SimpleCustomMenu)
    bpy.utils.unregister_class(RemeshOperator)

if __name__ == "__main__":
    register()

    # The menu can also be called from scripts
    bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)

To keep the depth my suggestion is to comment out the


#bpy.ops.object.modifier_apply(apply_as='DATA', modifier="sculptremesh")

Then you can change the depth value in the modifiers panel.

Put this together as a menu then reread your post.

Sorry, English is not my native Language, to what in my first post you try to point me?

I found the Menu in the User Preferences, and it work’s fantastic. It would be a bit nicer to have it in the Sculpt Menu Panel (the thing where i can choose the Brushes and change the Strength and Radius Values), but the current solution work fine by having a separate Preferences Window open.

To keep the depth my suggestion is to comment out the

To apply the Modifier is important, if not i see the new Topology but sculpt with the old one. But the Script always use the octree level i have set the last time, so there is no need to change something.

Many many thanks for your work, this solution makes this way to Sculpt a lot more comfortable for me.