Guest User

Untitled

a guest
Jul 22nd, 2020
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. import bpy
  2.  
  3. class SimpleOperator(bpy.types.Operator):
  4.     """Tooltip"""
  5.     bl_idname = "object.simple_operator"
  6.     bl_label = "Simple Object Operator"
  7.     bl_options = {'REGISTER','UNDO'}
  8.  
  9.     axis : bpy.props.EnumProperty (name="Axis", items=[('x','X',''),('y','Y',''),('z','Z','')], default="y")
  10.     threshold : bpy.props.FloatProperty (name="Threshold", min=0, default=0)
  11.     flip : bpy.props.BoolProperty (name="Flip", default = False)
  12.  
  13.     def draw(self, context):
  14.         layout = self.layout
  15.         layout.use_property_split = True
  16.         column = layout.column()
  17.  
  18.         row = column.row()
  19.         row.prop(self, "axis", expand=True)
  20.         layout.prop(self, "threshold", text="Threshold")
  21.         layout.prop(self, "flip", text="Flip")
  22.  
  23.  
  24.     @classmethod
  25.     def poll(cls, context):
  26.         return context.active_object is not None
  27.  
  28.     def main(self, context):
  29.         if self.axis == 'x':
  30.             if self.flip == False:
  31.                 return 'POSITIVE_X'
  32.             elif self.flip == True:
  33.                 return 'NEGATIVE_X'
  34.            
  35.         if self.axis == 'y':
  36.             if self.flip == False:
  37.                 return 'POSITIVE_Y'
  38.             elif self.flip == True:
  39.                 return 'NEGATIVE_Y'
  40.            
  41.         if self.axis == 'z':
  42.             if self.flip == False:
  43.                 return 'POSITIVE_Z'
  44.             elif self.flip == True:
  45.                 return 'NEGATIVE_Z'
  46.  
  47.     def execute(self, context):
  48.         print (self.main(context))
  49.         bpy.ops.mesh.symmetrize(threshold=self.threshold , direction=self.main(context))
  50.         return {'FINISHED'}
  51.  
  52.  
  53. def register():
  54.     bpy.utils.register_class(SimpleOperator)
  55.  
  56.  
  57. def unregister():
  58.     bpy.utils.unregister_class(SimpleOperator)
  59.  
  60.  
  61. if __name__ == "__main__":
  62.     register()
Advertisement
Add Comment
Please, Sign In to add comment