From 18d515887bc5c602e3b5fe944572254dee005cfb Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 21 Jan 2019 15:43:46 -0500 Subject: [PATCH] Fix bug with PyFile node open button The file was opened but would not be set in the node if the file had not been loaded into Blender previously. --- korman/operators/op_nodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/korman/operators/op_nodes.py b/korman/operators/op_nodes.py index 6fa1e96..9fc1462 100644 --- a/korman/operators/op_nodes.py +++ b/korman/operators/op_nodes.py @@ -37,16 +37,16 @@ class SelectFileOperator(NodeOperator, bpy.types.Operator): filename_property = StringProperty(description="Name of property to store filename in", options={"HIDDEN"}) def execute(self, context): + if bpy.data.texts.get(self.filename, None) is None: + bpy.data.texts.load(self.filepath) + else: + self.report({"WARNING"}, "A file named '{}' is already loaded. It will be used.".format(self.filename)) + dest = eval(self.data_path) if self.filepath_property: setattr(dest, self.filepath_property, self.filepath) if self.filename_property: setattr(dest, self.filename_property, self.filename) - - if bpy.data.texts.get(self.filename, None) is None: - bpy.data.texts.load(self.filepath) - else: - self.report({"WARNING"}, "A file named '{}' is already loaded. It will be used.".format(self.filename)) return {"FINISHED"} def invoke(self, context, event):