PyAPI: Use annotations for RNA definitions
- Logical use of fields since they define type information. - Avoids using ordered-dict metaclass. Properties using regular assignments will print a warning and load, however the order is undefined.
This commit is contained in:
@@ -45,7 +45,7 @@ class OBJECT_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_label = "Add Mesh Object"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
scale = FloatVectorProperty(
|
||||
scale: FloatVectorProperty(
|
||||
name="scale",
|
||||
default=(1.0, 1.0, 1.0),
|
||||
subtype='TRANSLATION',
|
||||
|
||||
@@ -30,10 +30,15 @@ class MyCustomSocket(NodeSocket):
|
||||
('DOWN', "Down", "Where your feet are"),
|
||||
('UP', "Up", "Where your head should be"),
|
||||
('LEFT', "Left", "Not right"),
|
||||
('RIGHT', "Right", "Not left")
|
||||
('RIGHT', "Right", "Not left"),
|
||||
)
|
||||
|
||||
my_enum_prop = bpy.props.EnumProperty(name="Direction", description="Just an example", items=my_items, default='UP')
|
||||
my_enum_prop: bpy.props.EnumProperty(
|
||||
name="Direction",
|
||||
description="Just an example",
|
||||
items=my_items,
|
||||
default='UP',
|
||||
)
|
||||
|
||||
# Optional function for drawing the socket input value
|
||||
def draw(self, context, layout, node, text):
|
||||
@@ -71,8 +76,8 @@ class MyCustomNode(Node, MyCustomTreeNode):
|
||||
# These work just like custom properties in ID data blocks
|
||||
# Extensive information can be found under
|
||||
# http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties
|
||||
my_string_prop = bpy.props.StringProperty()
|
||||
my_float_prop = bpy.props.FloatProperty(default=3.1415926)
|
||||
my_string_prop: bpy.props.StringProperty()
|
||||
my_float_prop: bpy.props.FloatProperty(default=3.1415926)
|
||||
|
||||
# === Optional Functions ===
|
||||
# Initialization function, called when a new node is created.
|
||||
|
||||
@@ -39,11 +39,11 @@ class SelectSideOfPlane(Operator):
|
||||
bl_label = "Select Side of Plane"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
plane_co = FloatVectorProperty(
|
||||
plane_co: FloatVectorProperty(
|
||||
size=3,
|
||||
default=(0, 0, 0),
|
||||
)
|
||||
plane_no = FloatVectorProperty(
|
||||
plane_no: FloatVectorProperty(
|
||||
size=3,
|
||||
default=(0, 0, 1),
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ class ExportSomeData(Operator, ExportHelper):
|
||||
# ExportHelper mixin class uses this
|
||||
filename_ext = ".txt"
|
||||
|
||||
filter_glob = StringProperty(
|
||||
filter_glob: StringProperty(
|
||||
default="*.txt",
|
||||
options={'HIDDEN'},
|
||||
maxlen=255, # Max internal buffer length, longer would be clamped.
|
||||
@@ -33,13 +33,13 @@ class ExportSomeData(Operator, ExportHelper):
|
||||
|
||||
# List of operator properties, the attributes will be assigned
|
||||
# to the class instance from the operator settings before calling.
|
||||
use_setting = BoolProperty(
|
||||
use_setting: BoolProperty(
|
||||
name="Example Boolean",
|
||||
description="Example Tooltip",
|
||||
default=True,
|
||||
)
|
||||
|
||||
type = EnumProperty(
|
||||
type: EnumProperty(
|
||||
name="Example Enum",
|
||||
description="Choose between two items",
|
||||
items=(
|
||||
|
||||
@@ -28,7 +28,7 @@ class ImportSomeData(Operator, ImportHelper):
|
||||
# ImportHelper mixin class uses this
|
||||
filename_ext = ".txt"
|
||||
|
||||
filter_glob = StringProperty(
|
||||
filter_glob: StringProperty(
|
||||
default="*.txt",
|
||||
options={'HIDDEN'},
|
||||
maxlen=255, # Max internal buffer length, longer would be clamped.
|
||||
@@ -36,13 +36,13 @@ class ImportSomeData(Operator, ImportHelper):
|
||||
|
||||
# List of operator properties, the attributes will be assigned
|
||||
# to the class instance from the operator settings before calling.
|
||||
use_setting = BoolProperty(
|
||||
use_setting: BoolProperty(
|
||||
name="Example Boolean",
|
||||
description="Example Tooltip",
|
||||
default=True,
|
||||
)
|
||||
|
||||
type = EnumProperty(
|
||||
type: EnumProperty(
|
||||
name="Example Enum",
|
||||
description="Choose between two items",
|
||||
items=(
|
||||
|
||||
@@ -49,25 +49,25 @@ class AddBox(bpy.types.Operator):
|
||||
bl_label = "Add Box"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
width = FloatProperty(
|
||||
width: FloatProperty(
|
||||
name="Width",
|
||||
description="Box Width",
|
||||
min=0.01, max=100.0,
|
||||
default=1.0,
|
||||
)
|
||||
height = FloatProperty(
|
||||
height: FloatProperty(
|
||||
name="Height",
|
||||
description="Box Height",
|
||||
min=0.01, max=100.0,
|
||||
default=1.0,
|
||||
)
|
||||
depth = FloatProperty(
|
||||
depth: FloatProperty(
|
||||
name="Depth",
|
||||
description="Box Depth",
|
||||
min=0.01, max=100.0,
|
||||
default=1.0,
|
||||
)
|
||||
layers = BoolVectorProperty(
|
||||
layers: BoolVectorProperty(
|
||||
name="Layers",
|
||||
description="Object Layers",
|
||||
size=20,
|
||||
@@ -75,15 +75,15 @@ class AddBox(bpy.types.Operator):
|
||||
)
|
||||
|
||||
# generic transform props
|
||||
view_align = BoolProperty(
|
||||
view_align: BoolProperty(
|
||||
name="Align to View",
|
||||
default=False,
|
||||
)
|
||||
location = FloatVectorProperty(
|
||||
location: FloatVectorProperty(
|
||||
name="Location",
|
||||
subtype='TRANSLATION',
|
||||
)
|
||||
rotation = FloatVectorProperty(
|
||||
rotation: FloatVectorProperty(
|
||||
name="Rotation",
|
||||
subtype='EULER',
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ class ModalOperator(bpy.types.Operator):
|
||||
bl_idname = "object.modal_operator"
|
||||
bl_label = "Simple Modal Operator"
|
||||
|
||||
first_mouse_x = IntProperty()
|
||||
first_value = FloatProperty()
|
||||
first_mouse_x: IntProperty()
|
||||
first_value: FloatProperty()
|
||||
|
||||
def modal(self, context, event):
|
||||
if event.type == 'MOUSEMOVE':
|
||||
|
||||
@@ -8,7 +8,7 @@ class ViewOperator(bpy.types.Operator):
|
||||
bl_idname = "view3d.modal_operator"
|
||||
bl_label = "Simple View Operator"
|
||||
|
||||
offset = FloatVectorProperty(
|
||||
offset: FloatVectorProperty(
|
||||
name="Offset",
|
||||
size=3,
|
||||
)
|
||||
|
||||
@@ -7,8 +7,10 @@ class MESH_UL_mylist(bpy.types.UIList):
|
||||
# E.g. VGROUP_EMPTY = 1 << 0
|
||||
|
||||
# Custom properties, saved with .blend file. E.g.
|
||||
# use_filter_empty = bpy.props.BoolProperty(name="Filter Empty", default=False, options=set(),
|
||||
# description="Whether to filter empty vertex groups")
|
||||
# use_filter_empty: bpy.props.BoolProperty(
|
||||
# name="Filter Empty", default=False, options=set(),
|
||||
# description="Whether to filter empty vertex groups",
|
||||
# )
|
||||
|
||||
# Called for each drawn item.
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
|
||||
|
||||
Reference in New Issue
Block a user