Browse Source

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.
pull/133/head
Adam Johnson 6 years ago
parent
commit
18d515887b
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 10
      korman/operators/op_nodes.py

10
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"}) filename_property = StringProperty(description="Name of property to store filename in", options={"HIDDEN"})
def execute(self, context): 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) dest = eval(self.data_path)
if self.filepath_property: if self.filepath_property:
setattr(dest, self.filepath_property, self.filepath) setattr(dest, self.filepath_property, self.filepath)
if self.filename_property: if self.filename_property:
setattr(dest, self.filename_property, self.filename) 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"} return {"FINISHED"}
def invoke(self, context, event): def invoke(self, context, event):

Loading…
Cancel
Save