Skip to main content
edited body
Source Link
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAllapplyall = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyallapplyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify")
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify")
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyall = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify")
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
added 1 character in body
Source Link
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify")
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify"
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify")
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
just class formatting.
Source Link
zeffii
  • 39.9k
  • 9
  • 106
  • 189
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify"
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
    if self       #Unhide all The Geo!
            bpy.Applyall:ops.mesh.reveal()
        #remove modifiers no one would 
 want applied in this instance       #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.modifier_removeeditmode_toggle(modifier="Bevel")     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.modifier_removemode_set(modifier="Solidify"mode='EDIT')
        #convert to  
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for sanitynow
        bpy.ops.object.convertmodifier_add(target='MESH'type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #apply the scale to keep me sane
        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
        
        #Start In Edit Mode
        bpy.ops.object.mode_set(mode='EDIT')
       
        #Unhide all The Geo!
        bpy.ops.mesh.reveal()
        
        #Clear SSharps Then Redo It
        #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        #bpy.ops.mesh.select_all(action='DESELECT')
        #bpy.ops.mesh.select_all(action='TOGGLE')
        
        #AR suggested using -1s instead of Zeroes
        #bpy.ops.transform.edge_bevelweight(value=-1)
        #bpy.ops.mesh.mark_sharp(clear=True)
        #bpy.ops.transform.edge_crease(value=-1)
        
        #then do the csharp operator stuff.
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        bpy.ops.mesh.select_all(action='DESELECT')
        
        #Sharpening now using the ssharpangle parameter.
        bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                            
        bpy.ops.transform.edge_bevelweight(value=1)
        bpy.ops.transform.edge_crease(value=1)
  #Sets Bevel To Bevel Width needs bpy.ops.mesh.mark_sharp()IF
        bpy.opscontext.object.editmode_toggle()     
        
    else:
        #Start In Edit Mode
        bpy.ops.objectmodifiers["Bevel"].mode_set(mode='EDIT')
       
        #Unhide all The Geo!
      width = bpy.ops.mesh.reveal()bevelwidth
        
        #Clear SSharps Then Redo It
        #bpy.ops.meshbpy.select_mode(use_extend=False, use_expand=False, type='EDGE')
        #bpycontext.opsobject.meshdata.select_all(action='DESELECT')
      use_auto_smooth = #bpy.ops.mesh.select_all(action='TOGGLE')True
        
        #AR suggested using -1s instead of Zeroes
   #now sets angle to Var #bpy.ops.transformangle.edge_bevelweight(value=-1)
        #bpybpy.opscontext.meshobject.mark_sharp(clear=True)
      data.auto_smooth_angle = #bpy.ops.transform.edge_crease(value=-1)angle
        
        #then do the csharp operator stuff.
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        bpy.ops.mesh.select_all(action='DESELECT')
        
        #Sharpening now using the ssharpangle parameter.
        bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                            
        bpy.ops.transform.edge_bevelweight(value=1)
        bpy.ops.transform.edge_crease(value=1)
        bpy.ops.mesh.mark_sharp()
        bpy.ops.object.editmode_toggleshade_smooth()     
        
    #keep the old here for now
    bpy.ops.object.modifier_add(type='BEVEL')
    bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
    bpy.context.object.modifiers["Bevel"].show_in_editmode = False
    bpy.context.object.modifiers["Bevel"].width = 0.0071
    bpy.context.object.modifiers["Bevel"].segments = 3
    bpy.context.object.modifiers["Bevel"].profile = 0.70
    bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

    #Sets Bevel To Bevel Width needs IF
    bpy.context.object.modifiers["Bevel"].width = bevelwidth
    
    bpy.context.object.data.use_auto_smooth = True
    
    #now sets angle to Var angle.
    bpy.context.object.data.auto_smooth_angle = angle
    
    
    bpy.ops.object.shade_smooth()
    
    return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
'''Sharpen With Modifiers and Bevelling'''
bl_idname = "csharpen.objects"
bl_label = "CSharpen"
bl_options = {'REGISTER', 'UNDO'} 

ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)

angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)

bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)

applyAll = BoolProperty(default = True)

originalbevel = FloatProperty()

    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
def draw(self, context):
    layout = self.layout

    box = layout.box()
    # DRAW YOUR PROPERTIES IN A BOX
    box.prop( self, 'ssharpangle', text = "SsharpAngle" )
    box.prop( self, 'angle', text = "SmoothingAngle" )
    box.prop( self, 'bevelwidth', text = "BevelWidth")
    box.prop( self, 'applyall', text = "ApplyAll")
  
def execute(self, context):
    #convert angle
    ob = bpy.context.selected_objects
    angle = self.angle
    originalbevel = self.originalbevel
    ssharpangle = self.ssharpangle
    angle = angle * (3.14159265359/180)
    ssharpangle = ssharpangle * (3.14159265359/180)
    bevelwidth = self.bevelwidth
    
    #Sets the Bevel Width To The Orig Bevel Width
    originalbevel = bpy.context.object.modifiers["Bevel"].width
           
    if self.Applyall:
        #remove modifiers no one would want applied in this instance
        bpy.ops.object.modifier_remove(modifier="Bevel")
        bpy.ops.object.modifier_remove(modifier="Solidify"
        #convert to mesh for sanity
        bpy.ops.object.convert(target='MESH')

        #apply the scale to keep me sane
        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
        
        #Start In Edit Mode
        bpy.ops.object.mode_set(mode='EDIT')
       
        #Unhide all The Geo!
        bpy.ops.mesh.reveal()
        
        #Clear SSharps Then Redo It
        #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        #bpy.ops.mesh.select_all(action='DESELECT')
        #bpy.ops.mesh.select_all(action='TOGGLE')
        
        #AR suggested using -1s instead of Zeroes
        #bpy.ops.transform.edge_bevelweight(value=-1)
        #bpy.ops.mesh.mark_sharp(clear=True)
        #bpy.ops.transform.edge_crease(value=-1)
        
        #then do the csharp operator stuff.
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        bpy.ops.mesh.select_all(action='DESELECT')
        
        #Sharpening now using the ssharpangle parameter.
        bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                            
        bpy.ops.transform.edge_bevelweight(value=1)
        bpy.ops.transform.edge_crease(value=1)
        bpy.ops.mesh.mark_sharp()
        bpy.ops.object.editmode_toggle()     
        
    else:
        #Start In Edit Mode
        bpy.ops.object.mode_set(mode='EDIT')
       
        #Unhide all The Geo!
        bpy.ops.mesh.reveal()
        
        #Clear SSharps Then Redo It
        #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        #bpy.ops.mesh.select_all(action='DESELECT')
        #bpy.ops.mesh.select_all(action='TOGGLE')
        
        #AR suggested using -1s instead of Zeroes
        #bpy.ops.transform.edge_bevelweight(value=-1)
        #bpy.ops.mesh.mark_sharp(clear=True)
        #bpy.ops.transform.edge_crease(value=-1)
        
        #then do the csharp operator stuff.
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
        bpy.ops.mesh.select_all(action='DESELECT')
        
        #Sharpening now using the ssharpangle parameter.
        bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                            
        bpy.ops.transform.edge_bevelweight(value=1)
        bpy.ops.transform.edge_crease(value=1)
        bpy.ops.mesh.mark_sharp()
        bpy.ops.object.editmode_toggle()     
        
    #keep the old here for now
    bpy.ops.object.modifier_add(type='BEVEL')
    bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
    bpy.context.object.modifiers["Bevel"].show_in_editmode = False
    bpy.context.object.modifiers["Bevel"].width = 0.0071
    bpy.context.object.modifiers["Bevel"].segments = 3
    bpy.context.object.modifiers["Bevel"].profile = 0.70
    bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

    #Sets Bevel To Bevel Width needs IF
    bpy.context.object.modifiers["Bevel"].width = bevelwidth
    
    bpy.context.object.data.use_auto_smooth = True
    
    #now sets angle to Var angle.
    bpy.context.object.data.auto_smooth_angle = angle
    
    
    bpy.ops.object.shade_smooth()
    
    return {'FINISHED'}    
class sharpenOperator(bpy.types.Operator):
    '''Sharpen With Modifiers and Bevelling'''
    bl_idname = "csharpen.objects"
    bl_label = "CSharpen"
    bl_options = {'REGISTER', 'UNDO'} 
    
    ssharpangle = FloatProperty(name="SSharpening Angle", description="Set SSharp Angle", default= 30.0, min = 0.0, max = 180.0)
    
    angle = FloatProperty(name="AutoSmooth Angle", description="Set AutoSmooth angle", default= 60.0, min = 0.0, max = 180.0)
    
    bevelwidth = FloatProperty(name="Bevel Width Amount", description="Set Bevel Width", default= 0.0071, min = 0.002, max = .25)
    
    applyAll = BoolProperty(default = True)
    
    originalbevel = FloatProperty()
    
    # ADD A DRAW FUNCTION TO DISPLAY PROPERTIES ON THE F6 MENU
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        # DRAW YOUR PROPERTIES IN A BOX
        box.prop( self, 'ssharpangle', text = "SsharpAngle" )
        box.prop( self, 'angle', text = "SmoothingAngle" )
        box.prop( self, 'bevelwidth', text = "BevelWidth")
        box.prop( self, 'applyall', text = "ApplyAll")
      
    def execute(self, context):
        #convert angle
        ob = bpy.context.selected_objects
        angle = self.angle
        originalbevel = self.originalbevel
        ssharpangle = self.ssharpangle
        angle = angle * (3.14159265359/180)
        ssharpangle = ssharpangle * (3.14159265359/180)
        bevelwidth = self.bevelwidth
        
        #Sets the Bevel Width To The Orig Bevel Width
        originalbevel = bpy.context.object.modifiers["Bevel"].width
               
        if self.Applyall:
            #remove modifiers no one would want applied in this instance
            bpy.ops.object.modifier_remove(modifier="Bevel")
            bpy.ops.object.modifier_remove(modifier="Solidify"
            #convert to mesh for sanity
            bpy.ops.object.convert(target='MESH')

            #apply the scale to keep me sane
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
            
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
             
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        else:
            #Start In Edit Mode
            bpy.ops.object.mode_set(mode='EDIT')
           
            #Unhide all The Geo!
            bpy.ops.mesh.reveal()
            
            #Clear SSharps Then Redo It
            #bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            #bpy.ops.mesh.select_all(action='DESELECT')
            #bpy.ops.mesh.select_all(action='TOGGLE')
            
            #AR suggested using -1s instead of Zeroes
            #bpy.ops.transform.edge_bevelweight(value=-1)
            #bpy.ops.mesh.mark_sharp(clear=True)
            #bpy.ops.transform.edge_crease(value=-1)
            
            #then do the csharp operator stuff.
            bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
            bpy.ops.mesh.select_all(action='DESELECT')
            
            #Sharpening now using the ssharpangle parameter.
            bpy.ops.mesh.edges_select_sharp(sharpness=ssharpangle)
                                
            bpy.ops.transform.edge_bevelweight(value=1)
            bpy.ops.transform.edge_crease(value=1)
            bpy.ops.mesh.mark_sharp()
            bpy.ops.object.editmode_toggle()     
            
        #keep the old here for now
        bpy.ops.object.modifier_add(type='BEVEL')
        bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
        bpy.context.object.modifiers["Bevel"].show_in_editmode = False
        bpy.context.object.modifiers["Bevel"].width = 0.0071
        bpy.context.object.modifiers["Bevel"].segments = 3
        bpy.context.object.modifiers["Bevel"].profile = 0.70
        bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

        #Sets Bevel To Bevel Width needs IF
        bpy.context.object.modifiers["Bevel"].width = bevelwidth
        
        bpy.context.object.data.use_auto_smooth = True
        
        #now sets angle to Var angle.
        bpy.context.object.data.auto_smooth_angle = angle
        
        
        bpy.ops.object.shade_smooth()
        
        return {'FINISHED'}    
tags, api link
Source Link
p2or
  • 16.1k
  • 10
  • 87
  • 146
Loading
Source Link
Loading