From 1d9d08fa1432552347aa62f2431a5bc516df340f Mon Sep 17 00:00:00 2001 From: Sergei Chipiga Date: Fri, 16 Jul 2021 22:35:12 +0300 Subject: [PATCH 1/2] Use type annotations in properties --- __init__.py | 12 +++++----- addon_updater_ops.py | 14 ++++++------ grease_pencil.py | 2 +- nodes/branch_node.py | 40 ++++++++++++++++----------------- nodes/grow_node.py | 32 +++++++++++++------------- nodes/node_tree.py | 8 +++---- nodes/root_node.py | 12 +++++----- nodes/split_node.py | 16 ++++++------- nodes/tree_parameters_node.py | 42 +++++++++++++++++------------------ nodes/trunk_node.py | 22 +++++++++--------- nodes/twig_node.py | 26 +++++++++++----------- wind.py | 6 ++--- 12 files changed, 116 insertions(+), 116 deletions(-) diff --git a/__init__.py b/__init__.py index db43121f..0336ea25 100644 --- a/__init__.py +++ b/__init__.py @@ -47,31 +47,31 @@ class Preferences(bpy.types.AddonPreferences): bl_idname = __package__ - auto_check_update = bpy.props.BoolProperty( + auto_check_update: bpy.props.BoolProperty( name="Auto-check for Update", description="If enabled, auto-check for updates using an interval", default=True, ) - updater_intrval_months = bpy.props.IntProperty( + updater_intrval_months: bpy.props.IntProperty( name='Months', description="Number of months between checking for updates", default=0, min=0 ) - updater_intrval_days = bpy.props.IntProperty( + updater_intrval_days: bpy.props.IntProperty( name='Days', description="Number of days between checking for updates", default=7, min=0, ) - updater_intrval_hours = bpy.props.IntProperty( + updater_intrval_hours: bpy.props.IntProperty( name='Hours', description="Number of hours between checking for updates", default=0, min=0, max=23 ) - updater_intrval_minutes = bpy.props.IntProperty( + updater_intrval_minutes: bpy.props.IntProperty( name='Minutes', description="Number of minutes between checking for updates", default=0, @@ -121,4 +121,4 @@ def unregister(): unregister_class(cls) # if __name__ == "__main__": -# register() \ No newline at end of file +# register() diff --git a/addon_updater_ops.py b/addon_updater_ops.py index c79c7923..40a49e5b 100755 --- a/addon_updater_ops.py +++ b/addon_updater_ops.py @@ -114,13 +114,13 @@ class addon_updater_install_popup(bpy.types.Operator): # if true, run clean install - ie remove all files before adding new # equivalent to deleting the addon and reinstalling, except the # updater folder/backup folder remains - clean_install = bpy.props.BoolProperty( + clean_install: bpy.props.BoolProperty( name="Clean install", description="If enabled, completely clear the addon's folder before installing new update, creating a fresh install", default=False, options={'HIDDEN'} ) - ignore_enum = bpy.props.EnumProperty( + ignore_enum: bpy.props.EnumProperty( name="Process update", description="Decide to install, ignore, or defer new addon update", items=[ @@ -256,7 +256,7 @@ class addon_updater_update_now(bpy.types.Operator): # if true, run clean install - ie remove all files before adding new # equivalent to deleting the addon and reinstalling, except the # updater folder/backup folder remains - clean_install = bpy.props.BoolProperty( + clean_install: bpy.props.BoolProperty( name="Clean install", description="If enabled, completely clear the addon's folder before installing new update, creating a fresh install", default=False, @@ -321,7 +321,7 @@ def target_version(self, context): i+=1 return ret - target = bpy.props.EnumProperty( + target: bpy.props.EnumProperty( name="Target version to install", description="Select the version to install", items=target_version @@ -330,7 +330,7 @@ def target_version(self, context): # if true, run clean install - ie remove all files before adding new # equivalent to deleting the addon and reinstalling, except the # updater folder/backup folder remains - clean_install = bpy.props.BoolProperty( + clean_install: bpy.props.BoolProperty( name="Clean install", description="If enabled, completely clear the addon's folder before installing new update, creating a fresh install", default=False, @@ -388,7 +388,7 @@ class addon_updater_install_manually(bpy.types.Operator): bl_description = "Proceed to manually install update" bl_options = {'REGISTER', 'INTERNAL'} - error = bpy.props.StringProperty( + error: bpy.props.StringProperty( name="Error Occurred", default="", options={'HIDDEN'} @@ -450,7 +450,7 @@ class addon_updater_updated_successful(bpy.types.Operator): bl_description = "Update installation response" bl_options = {'REGISTER', 'INTERNAL', 'UNDO'} - error = bpy.props.StringProperty( + error: bpy.props.StringProperty( name="Error Occurred", default="", options={'HIDDEN'} diff --git a/grease_pencil.py b/grease_pencil.py index cc54f017..a262ce3a 100644 --- a/grease_pencil.py +++ b/grease_pencil.py @@ -43,7 +43,7 @@ class ConnectStrokes(Operator): bl_label = "connect strokes" bl_options = {"REGISTER", "UNDO"} - point_dist = FloatProperty(min=0.001, default=.8) + point_dist: FloatProperty(min=0.001, default=.8) def execute(self, context): process_gp_layer(self.point_dist) diff --git a/nodes/branch_node.py b/nodes/branch_node.py index 6fa7074e..304e3ff6 100644 --- a/nodes/branch_node.py +++ b/nodes/branch_node.py @@ -7,26 +7,26 @@ class MtreeBranch(Node, BaseNode): bl_label = "Branch Node" - seed = IntProperty(update = BaseNode.property_changed) - advanced_settings = BoolProperty(default=False, update = BaseNode.property_changed) # show advanced properties - amount = IntProperty(min=0, default=20, update = BaseNode.property_changed) # number of splits - split_angle = FloatProperty(min=0, max=1.5, default=.6, update = BaseNode.property_changed) # angle of a fork - max_split_number = IntProperty(min=0, default=3, update = BaseNode.property_changed) # number of forks per split - radius = FloatProperty(min=0, max=1, default=.6, update = BaseNode.property_changed) # radius of split - end_radius = FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) - min_height = FloatProperty(min=0, max=.999, default=.1, name="start", update = BaseNode.property_changed) # min height at which a split occurs + seed: IntProperty(update = BaseNode.property_changed) + advanced_settings: BoolProperty(default=False, update = BaseNode.property_changed) # show advanced properties + amount: IntProperty(min=0, default=20, update = BaseNode.property_changed) # number of splits + split_angle: FloatProperty(min=0, max=1.5, default=.6, update = BaseNode.property_changed) # angle of a fork + max_split_number: IntProperty(min=0, default=3, update = BaseNode.property_changed) # number of forks per split + radius: FloatProperty(min=0, max=1, default=.6, update = BaseNode.property_changed) # radius of split + end_radius: FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) + min_height: FloatProperty(min=0, max=.999, default=.1, name="start", update = BaseNode.property_changed) # min height at which a split occurs - length = FloatProperty(min=0, default=7, update = BaseNode.property_changed) # length of trunk - shape_start = FloatProperty(min=0, default=1, update = BaseNode.property_changed) # length at the base of the tree - shape_end = FloatProperty(min=0, default=1, update = BaseNode.property_changed) # length at the end of the tree - shape_convexity = FloatProperty(default=.3, update = BaseNode.property_changed) # how curved the length will be in function of the height of the branch - resolution = FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops a branch has - randomness = FloatProperty(default=.15, update = BaseNode.property_changed) # how unregular the branches look - split_proba = FloatProperty(min=0, max=1, default=.1, update = BaseNode.property_changed) # how likely is a branch to fork - split_flatten = FloatProperty(min=0, max=1, default=.5, update = BaseNode.property_changed) # how constraint on the horizontal axis the splits are - can_spawn_leafs = BoolProperty(default=True, update = BaseNode.property_changed) - gravity_strength = FloatProperty(default=.3, update = BaseNode.property_changed) # how much branches go towards the floor/sky - floor_avoidance = FloatProperty(min=0, default=1, update = BaseNode.property_changed) # how much the branches avoid the floor + length: FloatProperty(min=0, default=7, update = BaseNode.property_changed) # length of trunk + shape_start: FloatProperty(min=0, default=1, update = BaseNode.property_changed) # length at the base of the tree + shape_end: FloatProperty(min=0, default=1, update = BaseNode.property_changed) # length at the end of the tree + shape_convexity: FloatProperty(default=.3, update = BaseNode.property_changed) # how curved the length will be in function of the height of the branch + resolution: FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops a branch has + randomness: FloatProperty(default=.15, update = BaseNode.property_changed) # how unregular the branches look + split_proba: FloatProperty(min=0, max=1, default=.1, update = BaseNode.property_changed) # how likely is a branch to fork + split_flatten: FloatProperty(min=0, max=1, default=.5, update = BaseNode.property_changed) # how constraint on the horizontal axis the splits are + can_spawn_leafs: BoolProperty(default=True, update = BaseNode.property_changed) + gravity_strength: FloatProperty(default=.3, update = BaseNode.property_changed) # how much branches go towards the floor/sky + floor_avoidance: FloatProperty(min=0, default=1, update = BaseNode.property_changed) # how much the branches avoid the floor properties = ["seed", "amount", "split_angle", "max_split_number", "radius", "end_radius", "min_height", "length", "shape_start", "shape_end", @@ -61,4 +61,4 @@ def execute(self, tree, input_node): links = output.links if len(links) > 0: links[0].to_node.execute(tree, self) - \ No newline at end of file + diff --git a/nodes/grow_node.py b/nodes/grow_node.py index f29c3921..0f49c3de 100644 --- a/nodes/grow_node.py +++ b/nodes/grow_node.py @@ -7,21 +7,21 @@ class MtreeGrow(Node, BaseNode): bl_label = "Grow Node" - seed = IntProperty() - length = FloatProperty(min=0, default=7, update = BaseNode.property_changed) # length of trunk - shape_start = FloatProperty(min=0, default=.5, update = BaseNode.property_changed) # length at the base of the tree - shape_end = FloatProperty(min=0, default=.5, update = BaseNode.property_changed) # length at the end of the tree - shape_convexity = FloatProperty(default=1, update = BaseNode.property_changed) # how curved the length will be in function of the height of the branch - resolution = FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops a branch has - randomness = FloatProperty(default=.1, update = BaseNode.property_changed) # how unregular the branches look - split_proba = FloatProperty(min=0, max=1, default=.1, update = BaseNode.property_changed) # how likely is a branch to fork - split_angle = FloatProperty(min=0, max=1, default=.3, update = BaseNode.property_changed) # angle of a fork - split_radius = FloatProperty(min=0, max=1, default=.9, update = BaseNode.property_changed) # radius of forked branches - split_flatten = FloatProperty(min=0, max=1, default=.5, update = BaseNode.property_changed) # how constraint on the horizontal axis the splits are - end_radius = FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) # the relative radius of vranches at the end of growth - can_spawn_leafs = BoolProperty(default=True, update = BaseNode.property_changed) - gravity_strength = FloatProperty(default=.1, update = BaseNode.property_changed) # how much branches go towards the floor/sky - floor_avoidance = FloatProperty(min=0, default=1, update = BaseNode.property_changed) # how much the branches avoid the floor + seed: IntProperty() + length: FloatProperty(min=0, default=7, update = BaseNode.property_changed) # length of trunk + shape_start: FloatProperty(min=0, default=.5, update = BaseNode.property_changed) # length at the base of the tree + shape_end: FloatProperty(min=0, default=.5, update = BaseNode.property_changed) # length at the end of the tree + shape_convexity: FloatProperty(default=1, update = BaseNode.property_changed) # how curved the length will be in function of the height of the branch + resolution: FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops a branch has + randomness: FloatProperty(default=.1, update = BaseNode.property_changed) # how unregular the branches look + split_proba: FloatProperty(min=0, max=1, default=.1, update = BaseNode.property_changed) # how likely is a branch to fork + split_angle: FloatProperty(min=0, max=1, default=.3, update = BaseNode.property_changed) # angle of a fork + split_radius: FloatProperty(min=0, max=1, default=.9, update = BaseNode.property_changed) # radius of forked branches + split_flatten: FloatProperty(min=0, max=1, default=.5, update = BaseNode.property_changed) # how constraint on the horizontal axis the splits are + end_radius: FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) # the relative radius of vranches at the end of growth + can_spawn_leafs: BoolProperty(default=True, update = BaseNode.property_changed) + gravity_strength: FloatProperty(default=.1, update = BaseNode.property_changed) # how much branches go towards the floor/sky + floor_avoidance: FloatProperty(min=0, default=1, update = BaseNode.property_changed) # how much the branches avoid the floor properties = ["seed", "length", "shape_start", "shape_end", "shape_convexity", "resolution", "randomness", "split_proba", "split_angle", "split_radius", "split_flatten", "end_radius", "can_spawn_leafs", "gravity_strength", "floor_avoidance"] @@ -49,4 +49,4 @@ def execute(self, tree, input_node): links = output.links if len(links) > 0: links[0].to_node.execute(tree, self) - \ No newline at end of file + diff --git a/nodes/node_tree.py b/nodes/node_tree.py index b6c407ca..11ea5cd9 100644 --- a/nodes/node_tree.py +++ b/nodes/node_tree.py @@ -25,8 +25,8 @@ class MtreeNodeTree(NodeTree): bl_label = "Mtree Node Tree" bl_icon = 'NODETREE' - preset_to_load = EnumProperty(name = "Presets", items = get_preset_list, description = "presets") - preset_to_save = StringProperty(name="name", default="default tree") + preset_to_load: EnumProperty(name = "Presets", items = get_preset_list, description = "presets") + preset_to_save: StringProperty(name="name", default="default tree") def save_as_json(self, return_string=False): ''' save node tree information in a json file ''' @@ -155,8 +155,8 @@ class MtreeSaveLoadPreset(Operator): bl_label = " Save or Load Preset" bl_options = {"REGISTER", "UNDO"} - node_group_name = StringProperty() - load = BoolProperty(default=False) + node_group_name: StringProperty() + load: BoolProperty(default=False) def execute(self, context): node_tree = bpy.data.node_groups[self.node_group_name] # get node tree diff --git a/nodes/root_node.py b/nodes/root_node.py index 840c84fb..6a375f3a 100644 --- a/nodes/root_node.py +++ b/nodes/root_node.py @@ -7,11 +7,11 @@ class MtreeRoots(Node, BaseNode): bl_label = "Roots Node" - seed = IntProperty(default=9, update = BaseNode.property_changed) - length = FloatProperty(min=0, default=14, update = BaseNode.property_changed) # length of trunk - resolution = FloatProperty(min=.002, default=2, update = BaseNode.property_changed) # how many loops the trunk has - split_proba = FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) - randomness = FloatProperty(min=0, max=0.5, default=.2, update = BaseNode.property_changed) + seed: IntProperty(default=9, update = BaseNode.property_changed) + length: FloatProperty(min=0, default=14, update = BaseNode.property_changed) # length of trunk + resolution: FloatProperty(min=.002, default=2, update = BaseNode.property_changed) # how many loops the trunk has + split_proba: FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) + randomness: FloatProperty(min=0, max=0.5, default=.2, update = BaseNode.property_changed) properties = ["seed", "length", "resolution", "split_proba", "randomness"] @@ -28,4 +28,4 @@ def execute(self, tree, input_node): random.seed(self.seed) creator = self.id_data.nodes.find(self.name) # get index of node in node tree and use it as tree function identifier - tree.roots(self.length, self.resolution, self.split_proba, self.randomness, creator) \ No newline at end of file + tree.roots(self.length, self.resolution, self.split_proba, self.randomness, creator) diff --git a/nodes/split_node.py b/nodes/split_node.py index db34cde3..a137381f 100644 --- a/nodes/split_node.py +++ b/nodes/split_node.py @@ -7,13 +7,13 @@ class MtreeSplit(Node, BaseNode): bl_label = "Split Node" - seed = IntProperty(update = BaseNode.property_changed) - amount = IntProperty(min=0, default=20, update = BaseNode.property_changed) # number of splits - split_angle = FloatProperty(min=0, max=1.5, default=.6, update = BaseNode.property_changed) # angle of a fork - max_split_number = IntProperty(min=0, default=3, update = BaseNode.property_changed) # number of forks per split - radius = FloatProperty(min=0, max=1, default=.6, update = BaseNode.property_changed) # radius of split - start = FloatProperty(min=0, max=.999, default=0.3, name="start", update = BaseNode.property_changed) # min height at which a split occurs - end = FloatProperty(min=0, max=1, default=1, update = BaseNode.property_changed) + seed: IntProperty(update = BaseNode.property_changed) + amount: IntProperty(min=0, default=20, update = BaseNode.property_changed) # number of splits + split_angle: FloatProperty(min=0, max=1.5, default=.6, update = BaseNode.property_changed) # angle of a fork + max_split_number: IntProperty(min=0, default=3, update = BaseNode.property_changed) # number of forks per split + radius: FloatProperty(min=0, max=1, default=.6, update = BaseNode.property_changed) # radius of split + start: FloatProperty(min=0, max=.999, default=0.3, name="start", update = BaseNode.property_changed) # min height at which a split occurs + end: FloatProperty(min=0, max=1, default=1, update = BaseNode.property_changed) properties = ["seed", "amount", "split_angle", "max_split_number", "radius", "start", "end"] @@ -38,4 +38,4 @@ def execute(self, tree, input_node): links = output.links if len(links) > 0: links[0].to_node.execute(tree, self) - \ No newline at end of file + diff --git a/nodes/tree_parameters_node.py b/nodes/tree_parameters_node.py index 5ae4ba47..d22f00a8 100644 --- a/nodes/tree_parameters_node.py +++ b/nodes/tree_parameters_node.py @@ -13,29 +13,29 @@ class MtreeParameters(Node, BaseNode): bl_label = "Tree parameters" - auto_update = BoolProperty(update = BaseNode.property_changed) - mesh_type = bpy.props.EnumProperty( + auto_update: BoolProperty(update = BaseNode.property_changed) + mesh_type: bpy.props.EnumProperty( items=[('final', 'Final', ''), ('preview', 'Preview', '')], name="output", default="preview", update = BaseNode.property_changed) - resolution = IntProperty(min=0, default=16, update = BaseNode.property_changed) - create_leafs = BoolProperty(default = False, update = BaseNode.property_changed) - leaf_amount = IntProperty(min=1, default=3000, update = BaseNode.property_changed) - leaf_max_radius = FloatProperty(min=0, default=.1, update = BaseNode.property_changed) - leaf_dupli_object = PointerProperty(type=bpy.types.Object, name="leaf", update = BaseNode.property_changed) - leaf_size = FloatProperty(min=0, default=.1, update = BaseNode.property_changed) - leaf_extremity_only = BoolProperty(name="extremities only", default=False, update = BaseNode.property_changed) - leaf_spread = FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) - leaf_flatten = FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) - leaf_weight = FloatProperty(min=-1, max=1, default=0, update = BaseNode.property_changed) + resolution: IntProperty(min=0, default=16, update = BaseNode.property_changed) + create_leafs: BoolProperty(default = False, update = BaseNode.property_changed) + leaf_amount: IntProperty(min=1, default=3000, update = BaseNode.property_changed) + leaf_max_radius: FloatProperty(min=0, default=.1, update = BaseNode.property_changed) + leaf_dupli_object: PointerProperty(type=bpy.types.Object, name="leaf", update = BaseNode.property_changed) + leaf_size: FloatProperty(min=0, default=.1, update = BaseNode.property_changed) + leaf_extremity_only: BoolProperty(name="extremities only", default=False, update = BaseNode.property_changed) + leaf_spread: FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) + leaf_flatten: FloatProperty(min=0, max=1, default=.2, update = BaseNode.property_changed) + leaf_weight: FloatProperty(min=-1, max=1, default=0, update = BaseNode.property_changed) - create_armature = BoolProperty(default=False, update = BaseNode.property_changed) - armature_min_radius = FloatProperty(min=0, max=1, default=.08, update = BaseNode.property_changed) + create_armature: BoolProperty(default=False, update = BaseNode.property_changed) + armature_min_radius: FloatProperty(min=0, max=1, default=.08, update = BaseNode.property_changed) - has_changed = BoolProperty(default = True) # has there been a change in the node tree or any of its parameters - active_tree_object = PointerProperty(type=bpy.types.Object) # referece to last tree made, used when updating + has_changed: BoolProperty(default = True) # has there been a change in the node tree or any of its parameters + active_tree_object: PointerProperty(type=bpy.types.Object) # referece to last tree made, used when updating - last_execution_info = StringProperty() # this propperty is not be in the properties variable in order to avoid loop + last_execution_info: StringProperty() # this propperty is not be in the properties variable in order to avoid loop properties = ["resolution", "create_leafs", "leaf_amount", "leaf_max_radius", "leaf_weight", "leaf_dupli_object", "leaf_size", "leaf_extremity_only", "leaf_flatten", "leaf_spread", "mesh_type", "create_armature", "armature_min_radius"] @@ -414,7 +414,7 @@ class ExecuteMtreeNodeTreeOperator(Operator): """Execute or update tree""" bl_idname = "object.mtree_execute_tree" bl_label = "Execute Mtree node tree" - node_group_name = StringProperty() + node_group_name: StringProperty() def execute(self, context): node = [i for i in bpy.data.node_groups[self.node_group_name].nodes if i.bl_idname == "MtreeParameters"][0] @@ -426,7 +426,7 @@ class RandomizeTreeOperator(Operator): bl_idname = "mtree.randomize_tree" bl_label = "Randomize Mtree node tree" - node_group_name = StringProperty() + node_group_name: StringProperty() def execute(self, context): parameters_node = [i for i in bpy.data.node_groups[self.node_group_name].nodes if i.bl_idname == "MtreeParameters"][0] @@ -443,10 +443,10 @@ class ResetActiveTreeObject(Operator): bl_idname = "mtree.reset_active_tree_object" bl_label = "Reset Active Tree Object" - node_group_name = StringProperty() + node_group_name: StringProperty() def execute(self, context): parameters_node = [i for i in bpy.data.node_groups[self.node_group_name].nodes if i.bl_idname == "MtreeParameters"][0] parameters_node.active_tree_object = None parameters_node.has_changed = True - return {'FINISHED'} \ No newline at end of file + return {'FINISHED'} diff --git a/nodes/trunk_node.py b/nodes/trunk_node.py index 90b7c615..a7b33970 100644 --- a/nodes/trunk_node.py +++ b/nodes/trunk_node.py @@ -8,15 +8,15 @@ class MtreeTrunk(Node, BaseNode): bl_label = "Trunk Node" - seed = IntProperty(default=1, update = BaseNode.property_changed) - length = FloatProperty(min=0, default=25, update = BaseNode.property_changed) # length of trunk - radius = FloatProperty(min=.0005, default=.5, update = BaseNode.property_changed) # radius of trunk - end_radius = FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) # radius at the end of the trunk - resolution = FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops the trunk has - shape = FloatProperty(min=0.01, default=1, update = BaseNode.property_changed) # how the radius decreases with length - randomness = FloatProperty(min=0, max=0.5, default=.1, update = BaseNode.property_changed) - axis_attraction = FloatProperty(min=0, max=1, default=.25, update = BaseNode.property_changed) - use_grease_pencil = BoolProperty(default=False, update = BaseNode.property_changed) + seed: IntProperty(default=1, update = BaseNode.property_changed) + length: FloatProperty(min=0, default=25, update = BaseNode.property_changed) # length of trunk + radius: FloatProperty(min=.0005, default=.5, update = BaseNode.property_changed) # radius of trunk + end_radius: FloatProperty(min=0, max=1, default=0, update = BaseNode.property_changed) # radius at the end of the trunk + resolution: FloatProperty(min=.002, default=1, update = BaseNode.property_changed) # how many loops the trunk has + shape: FloatProperty(min=0.01, default=1, update = BaseNode.property_changed) # how the radius decreases with length + randomness: FloatProperty(min=0, max=0.5, default=.1, update = BaseNode.property_changed) + axis_attraction: FloatProperty(min=0, max=1, default=.25, update = BaseNode.property_changed) + use_grease_pencil: BoolProperty(default=False, update = BaseNode.property_changed) properties = ["seed", "length", "radius", "end_radius", "resolution", "shape", "randomness", "axis_attraction", "use_grease_pencil"] @@ -57,10 +57,10 @@ class UpdateGreasePencil(Operator): bl_idname = "mtree.update_gp_strokes" bl_label = "Reset Active Tree Object" - node_group_name = StringProperty() + node_group_name: StringProperty() def execute(self, context): parameters_node = [i for i in bpy.data.node_groups[self.node_group_name].nodes if i.bl_idname == "MtreeParameters"][0] parameters_node.has_changed = True parameters_node.execute() - return {'FINISHED'} \ No newline at end of file + return {'FINISHED'} diff --git a/nodes/twig_node.py b/nodes/twig_node.py index b6ac15d0..84efc68f 100644 --- a/nodes/twig_node.py +++ b/nodes/twig_node.py @@ -12,20 +12,20 @@ class MtreeTwig(Node, BaseNode): bl_label = "Twig Node" - seed = IntProperty(default=1) - length = FloatProperty(min=.01, default=3) - radius = FloatProperty(min=0.001, default=.15) - branch_number = IntProperty(min=0, default=6) - randomness = FloatProperty(default=.7, min=0) - resolution = FloatProperty(min=.1, default=8) - gravity_strength = FloatProperty(default=4) - flatten = FloatProperty(min=0, max=1, default=.6) - leaf_object = PointerProperty(type=bpy.types.Object) - leaf_type = EnumProperty( + seed: IntProperty(default=1) + length: FloatProperty(min=.01, default=3) + radius: FloatProperty(min=0.001, default=.15) + branch_number: IntProperty(min=0, default=6) + randomness: FloatProperty(default=.7, min=0) + resolution: FloatProperty(min=.1, default=8) + gravity_strength: FloatProperty(default=4) + flatten: FloatProperty(min=0, max=1, default=.6) + leaf_object: PointerProperty(type=bpy.types.Object) + leaf_type: EnumProperty( items=[('palmate', 'Palmate', ''), ('serrate', 'Serrate', ''), ('palmatisate', 'Palmatisate', ''), ('custom', 'Custom', '')], name="leaf type", default="palmate") - leaf_size = FloatProperty(min=0, default=1) + leaf_size: FloatProperty(min=0, default=1) def init(self, context): self.name = MtreeTwig.bl_label @@ -80,8 +80,8 @@ class TwigOperator(Operator): bl_label = " Make Twig" bl_options = {"REGISTER", "UNDO"} - node_group_name = StringProperty() - node_name = StringProperty() + node_group_name: StringProperty() + node_name: StringProperty() def execute(self, context): node = bpy.data.node_groups[self.node_group_name].nodes[self.node_name] diff --git a/wind.py b/wind.py index b7b70a7f..96e46ff9 100644 --- a/wind.py +++ b/wind.py @@ -55,8 +55,8 @@ class FastWind(Operator): bl_label = "Fast Wind" bl_options = {"REGISTER", "UNDO"} - strength = FloatProperty(default=1) - speed = FloatProperty(min=0, default=.5) + strength: FloatProperty(default=1) + speed: FloatProperty(min=0, default=.5) def draw(self, context): layout = self.layout @@ -72,4 +72,4 @@ def execute(self, context): self.report({'ERROR'}, "No armature object selected") return {'CANCELLED'} - return {'FINISHED'} \ No newline at end of file + return {'FINISHED'} From ccd5a23ecd14613dbf63e429c9b4628b014004a6 Mon Sep 17 00:00:00 2001 From: Sergei Chipiga Date: Fri, 16 Jul 2021 22:51:05 +0300 Subject: [PATCH 2/2] Replace python deprecated method --- nodes/tree_parameters_node.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nodes/tree_parameters_node.py b/nodes/tree_parameters_node.py index d22f00a8..b2c84b96 100644 --- a/nodes/tree_parameters_node.py +++ b/nodes/tree_parameters_node.py @@ -72,10 +72,10 @@ def execute(self): except IndexError: ShowMessageBox("The tree needs a trunk node in order to execute", "Invalid node tree", "ERROR") return - t0 = time.clock() + t0 = time.time() if change_level != "particle_system": trunk.execute(tree) - t1 = time.clock() + t1 = time.time() if self.create_armature: armature_ob = create_armature(self.armature_min_radius, tree, armature_ob) @@ -91,14 +91,14 @@ def execute(self): if self.create_armature: arm = tree_ob.modifiers.new("armature", type='ARMATURE') arm.object = armature_ob - t2 = time.clock() + t2 = time.time() if self.create_leafs: if change_level in {"tree_execution", "leafs_emitter"}: leaf_ob = generate_leafs_object(tree, self.leaf_amount, self.leaf_weight, self.leaf_max_radius, self.leaf_spread, self.leaf_flatten, self.leaf_extremity_only, leaf_ob, tree_ob) create_particle_system(leaf_ob, self.leaf_amount, self.leaf_dupli_object, self.leaf_size) elif leaf_ob != None: # if there should not be leafs yet an emitter exists, delete it bpy.data.objects.remove(leaf_ob, do_unlink=True) # delete leaf object - t3 = time.clock() + t3 = time.time() self.has_changed = False print("tree generation duration : {}".format(t1-t0)) print("mesh creation duration : {}".format(t2-t1)) @@ -191,9 +191,9 @@ def get_current_object(tree_ob_type, active_tree): def generate_tree_object(ob, tree, resolution, tree_property="is_tree"): ''' Create the tree mesh/object ''' - t0 = time.clock() + t0 = time.time() verts, faces, radii, uvs, bone_weights = tree.build_mesh_data(resolution) # tree mesh data - dt = time.clock() - t0 + dt = time.time() - t0 print("mesh data creation : {}".format(dt)) mesh = bpy.data.meshes.new("tree") material = None # material of tree object