Skip to content
Snippets Groups Projects
Select Git revision
  • 171648da578dc2783e17a9fd456893f5bb4ff9d6
  • master default protected
  • blender-v3.6-release
  • main
  • blender-v4.1-release
  • blender-v4.0-release
  • blender-v3.3-release
  • asset-shelf
  • blender-v3.5-release
  • brush-assets-project
  • blender-v2.93-release
  • blender-v3.4-release
  • xr-dev
  • bholodeck-v3.3
  • blender-v3.2-release
  • temp-xr-tracker
  • blender-v3.1-release
  • screenshots-manual
  • gltf_vtree
  • blender-v2.83-release
  • blender-v3.0-release
  • v3.6.18
  • v3.6.19
  • v3.6.20
  • v3.6.21
  • v3.6.22
  • v3.6.23
  • v4.1.1
  • v4.1.0
  • v3.6.10
  • v3.6.11
  • v3.6.12
  • v3.6.13
  • v3.6.14
  • v3.6.15
  • v3.6.16
  • v3.6.17
  • v3.6.9
  • v3.3.16
  • v3.6.8
  • v3.3.15
41 results

preferences.py

Blame
  • user avatar
    meta-androcto authored
    4fa93f6e
    History
    preferences.py 3.91 KiB
    import bpy
    
    from bpy.types import (
        AddonPreferences,
        PropertyGroup,
        )
    from bpy.props import (
        StringProperty,
        BoolProperty,
        EnumProperty,
        IntProperty,
        FloatProperty
        )
    from math import radians
    
    from .enum_values import *
    
    # Addon Preferences
    class VIEW3D_MT_materialutilities_preferences(AddonPreferences):
        bl_idname = __package__
    
        new_material_name: StringProperty(
                name = "New Material name",
                description = "What Base name pattern to use for a new created Material\n"
                              "It is appended by an automatic numeric pattern depending\n"
                              "on the number of Scene's materials containing the Base",
                default = "Unnamed Material",
                )
        override_type: EnumProperty(
                name = 'Assignment method',
                description = '',
                items = mu_override_type_enums
                )
        fake_user: EnumProperty(
                name = "Set Fake User",
                description = "Default option for the Set Fake User (Turn fake user on or off)",
                items = mu_fake_user_set_enums,
                default = 'TOGGLE'
                )
        fake_user_affect: EnumProperty(
                name = "Affect",
                description = "Which materials of objects to affect",
                items = mu_fake_user_affect_enums,
                default = 'UNUSED'
                )
        link_to: EnumProperty(
                name = "Change Material Link To",
                description = "Default option for the Change Material Link operator",
                items = mu_link_to_enums,
                default = 'OBJECT'
                )
        link_to_affect: EnumProperty(
                name = "Affect",
                description = "Which materials of objects to affect by default with Change Material Link",
                items = mu_link_affect_enums,
                default = 'SELECTED'
                )
        search_show_limit: IntProperty(
                name = "Show 'Search' Limit",
                description = "How many materials should there be before the 'Search' option is shown "
                              "in the Assign Material and Select By Material menus\n"
                              "Set it to 0 to always show 'Search'",
                min = 0,
                default = 0
                )
    
        set_smooth_affect: EnumProperty(
                name = "Set Auto Smooth Affect",
                description = "Which objects to affect",
                items = mu_affect_enums,
                default = 'SELECTED'
                )
        auto_smooth_angle: FloatProperty(
                name = "Auto Smooth Angle",
                description = "Maximum angle between face normals that will be considered as smooth",
                subtype = 'ANGLE',
                min = 0,
                max = radians(180),
                default = radians(35)
                )
    
        def draw(self, context):
            layout = self.layout
            layout.use_property_split = True
    
            box = layout.box()
            box.label(text = "Defaults")
    
            a = box.box()
            a.label(text = "Assign Material")
            a.prop(self, "new_material_name", icon = "MATERIAL")
            a.prop(self, "override_type", expand = False)
    
            b = box.box()
            b.label(text = "Set Fake User")
            b.row().prop(self, "fake_user", expand = False)
            b.row().prop(self, "fake_user_affect", expand = False)
    
            c = box.box()
            c.label(text = "Set Link To")
            c.row().prop(self, "link_to", expand = False)
            c.row().prop(self, "link_to_affect", expand = False)
    
            d = box.box()
            d.label(text = "Set Auto Smooth")
            d.row().prop(self, "auto_smooth_angle", expand = False)
            d.row().prop(self, "set_smooth_affect", expand = False)
    
            box = layout.box()
            box.label(text = "Miscellaneous")
    
            #col = box.column()
            #row = col.split(factor = 0.5)
            box.prop(self, "search_show_limit", expand = False)
    
    
    def materialutilities_get_preferences(context):
        return context.preferences.addons[__package__].preferences