Is it possible to have a toggle to switch between grid units and scale@same time like:
you could for sure bundle two or more actions into one operator and bind that to a key, granted you could do the same in UI in multiple steps (is it the case?)
Im very new to scripting. Id like to have a button in the tools panel just a toggle to switch between the 2 sets of settings in the pic.
quick and dirty script:
import bpy
class VIEW3D_OT_grid_switch(bpy.types.Operator):
"""Tooltip"""
bl_idname = "view3d.grid_switch"
bl_label = "Grid Switch"
scale = bpy.props.FloatProperty(default=1.0, subtype='UNSIGNED')
subdivisions = bpy.props.IntProperty(default=10, min=1, max=1024)
@classmethod
def poll(cls, context):
return 'VIEW_3D' in (a.type for a in context.screen.areas)
def execute(self, context):
for area in context.screen.areas:
if area.type == 'VIEW_3D':
area.spaces[0].grid_scale = self.scale
area.spaces[0].grid_subdivisions = self.subdivisions
return {'FINISHED'}
class VIEW3D_PT_grid_switch(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "GRID SWITCH"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
def draw(self, context):
layout = self.layout
col = layout.column()
col.label("Scale / Subdivisions")
prop = col.operator(VIEW3D_OT_grid_switch.bl_idname, text="0.125 / 10")
prop.scale = 0.125
prop.subdivisions = 10
prop = col.operator(VIEW3D_OT_grid_switch.bl_idname, text="0.156 / 8")
prop.scale = 0.156
prop.subdivisions = 8
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
you can use the context menu to bind shortcuts to the two buttons
Thank YOU very much