0
$\begingroup$

enter image description here I want to use mean crease in my python script, but i cant access its code via "edit source". I need a button which clears all creases on selected edges with single click, and put it in my custom pie menu. I've found some info on it : mean crease function is scripted with C. Any ideas how to get "mean crease" in python?

$\endgroup$
  • $\begingroup$ In object mode you find it in obj.data.edges.crease. While in edit mode you would need to use bmesh.from_edit_mesh() and get the edge crease from the custom data layers. $\endgroup$ – sambler Apr 11 '17 at 4:58
2
$\begingroup$

Here is the line you need

bpy.ops.transform.edge_crease(value=-1.0)

import bpy

class UIPanel(bpy.types.Panel):
    bl_label = "Crease Clear"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None) and (context.mode == "EDIT_MESH")

    def draw(self, context):
        self.layout.operator("crease.clear", text='Crease Clear')

class OBJECT_OT_HelloButton(bpy.types.Operator):
    bl_idname = "crease.clear"
    bl_label = "Crease Clear"
    country = bpy.props.StringProperty()

    def execute(self, context):
        bpy.ops.transform.edge_crease(value=-1.0)
        return{'FINISHED'}    

bpy.utils.register_module(__name__)

enter image description here

Если ты хочешь чтобы кнопка осталась в системе, после перезапуска блендера, сохрани текст в файл с форматом .py и нажми последовательно эти кнопки

If you want the button to remain in the system, after restarting the blender, save the text in a file with the format .py and click these buttons sequentially

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thx alot. This code works for pie menu's too. Thats what i was looking for. $\endgroup$ – Евгений Гейзер May 9 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.