Recent Posts

How To Get Icon List In Blender

GOAL

Today’s goal is to show Icon Viewer that shows the list of icon we can use in Blender and use it.

Icon Viewer

Environment

Blender2.83(LTS)
Windows10

Method

1. Activate addon “Development Icon Viewer”

2. Open Icon Viewer

Open text Editor and click “Dev” tab.

Click on any icon you like and it’s name will be copied to the clipboard. Then paste it into your editor.

Examples

1. Operator button

def draw(self, context):
    layout = self.layout
    col = layout.column(align=True)
    col.operator("mesh.primitive_monkey_add", icon="MONKEY")

2. EnumProperty

class MyProp(bpy.types.PropertyGroup):
    items = [("id1", "name1", "description 1", "HELP", 0),
             ("id2", "name2", "description 2", "GHOST_ENABLED", 1),
             ("id3", "mame3", "description 3", "FUND", 2),]
    enum: bpy.props.EnumProperty(items=items)
def draw(self, context):
    layout = self.layout
    col = layout.column(align=True)
    col.prop(context.scene.MyProp, "enum")

How To Pass Arguments To Custom Operator In Blender Python

GOAL

Today’s goal is to create operator that takes arguments in Blender Python.

The following is a custom operator that takes 2 argument “count_x” and “count_y”, and add cube object in the form of count_x rows and count_y columns.

Environment

Blender 2.83(LTS)
Windows10

Method

1. Create operator with properties

Pass the argument values through the properties to custom operator. Use “:” to add property in Blender custom operator as below. Check “Operator Example” in Blender manual for details.

class ADDMATRIX_add_cube(bpy.types.Operator):
    bl_idname = 'add_matrix_obj.add_cube'
    bl_label = "Add matrix cube"
    bl_options = {'REGISTER', "UNDO"}

    input1: bpy.props.IntProperty() # add argument1 as property "input1"
    input2: bpy.props.IntProperty() # add argument2 as property "input2"

    def execute(self, context):
        for xi in range(self.input1):
            x = xi*1.2
            for yi in range(self.input2):
                y = yi*1.2
                bpy.ops.mesh.primitive_cube_add(size=0.5, enter_editmode=False, align='WORLD', location=(x, y, 0))
        return {'FINISHED'}

You can execute operator with passing values of arguments “input1” and “input2” as below.

(more…)

List Of Blender Properties

GOAL

Today’s goal is to list up property UI that can be used in Blender Addon.
Reference: Property Definitions

Environment

Blender 2.83(LTS)
Windows10

List of Properties

  • BoolProperty
  • BoolVectorProperty
  • CollectionProperty
  • EnumProperty
  • FloatProperty
  • FloatVectorProperty
  • IntProperty
  • IntVectorProperty
  • PointerProperty
  • StringProperty

How each property looks like

BoolProperty

bool: bpy.props.BoolProperty()

BoolVectorProperty

bool_vector: bpy.props.BoolVectorProperty()

subtypes of BoolVectorProperty

The UI style or label differs according to its subtype.

bool_vector_color: bpy.props.BoolVectorProperty(subtype='COLOR')
bool_vector_translation: bpy.props.BoolVectorProperty(subtype='TRANSLATION')
# and more...

CollectionProperty

UILayout.prop() just shows the number of CollectionProperty. (Use “template_list” to show the item list of CollectionProperty)

class PropertySetTest(bpy.types.PropertyGroup):
    test_int: bpy.props.IntProperty()
    test_string: bpy.props.StringProperty()
collection: bpy.props.CollectionProperty(type=PropertySetTest)

EnumProperty

items = [("id1", "name1", "description 1", "MESH_CUBE", 0),
         ("id2", "name2", "description 2", "MESH_TORUS", 1),
         ("id3", "mame3", "description 3", "CONE", 2),]
enum: bpy.props.EnumProperty(items=items)

FloatProperty

float: bpy.props.FloatProperty()

subtypes of FloatProperty

float_pixel: bpy.props.FloatProperty(subtype="PIXEL")
float_unsigned: bpy.props.FloatProperty(subtype="UNSIGNED")
# and more...

units of FloatProperty

float_none: bpy.props.FloatProperty(unit='NONE')
float_length: bpy.props.FloatProperty(unit='LENGTH')
# and more...

FloatVectorProperty

float_vector: bpy.props.FloatVectorProperty()

subtypes of FloatVectorProperty

units of FloatVectorProperty

IntProperty

subtypes of IntVectorProperty

IntVectorProperty

subtypes of FloatVectorProperty

PointerProperty

PointerProperty takes argument ‘type’ to set the type of pointer.

pointer_scene: bpy.props.PointerProperty(type=bpy.types.Scene)
pointer_object: bpy.props.PointerProperty(type=bpy.types.Object)
pointer_matarial: bpy.props.PointerProperty(type=bpy.types.Material)
pointer_mesh: bpy.props.PointerProperty(type=bpy.types.Mesh)
pointer_image: bpy.props.PointerProperty(type=bpy.types.Image)
pointer_brush: bpy.props.PointerProperty(type=bpy.types.Brush)
pointer_camera: bpy.props.PointerProperty(type=bpy.types.Camera)
pointer_light: bpy.props.PointerProperty(type=bpy.types.Light)

StringProperty

subtypes of FloatVectorProperty

Categories

AfterEffects Algorithm Artificial Intelligence Blender C++ Computer Graphics Computer Science Daily Life DataAnalytics Event Game ImageProcessing JavaScript Kotlin mathematics Maya PHP Python SoftwareEngineering Tips Today's paper Tools TroubleShooting Unity Visual Sudio Web Windows WordPress 未分類