01-15-2024, 04:15 PM
I was able to get the script to work, but now I have another issue: how do I properly return two variables from a script? I've been able to have one return variable work successfully in the past, but I'm having trouble with two. Here's the revised code:
The code works fine on its own, with no errors and the messages displaying appropriately in the error console. But when I call it from another script like so:
I get a "RuntimeError: execution error" from Gimp. The second script so far only contains that line of code within its main function.
I have also tried putting the variables into a list within both scripts:
which got me the same results. I've also tried running it with only one return variable, and it worked fine with returning either variable on its own. So I would assume that the issue is however I'm setting up the two return variables. The documentation doesn't cover this, so I'm at a loss.
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from gimpfu import*
def getPathSave(image, layer):
filePath = pdb.gimp_image_get_filename(image)
pdb.gimp_file_save(image, layer, filePath, filePath)
folderName = os.path.dirname(filePath)
fileName = os.path.basename(filePath)
pdb.gimp_message("folderName = " + str(folderName))
pdb.gimp_message("fileName = " + str(fileName))
return folderName, fileName
register(
"python_fu_marvelmods_basic_get_path_save",
"Saves the file and collects file path information. Returns the folder that the file is in, as well as its name (without the extension).",
"Saves the file and collects file path information. Returns the folder that the file is in, as well as its name (without the extension).",
"BaconWizard17",
"BaconWizard17",
"January 2024",
"Get File Path and Save",
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Layer, mask, or channel", None)
],
[
(PF_STRING, "folderName", "The folder that the file is in"),
(PF_STRING, "fileName", "The file name")
],
getPathSave,
menu='<Image>/Marvel Mods/Basic Procedures'
)
main()
The code works fine on its own, with no errors and the messages displaying appropriately in the error console. But when I call it from another script like so:
Code:
folderName, fileName = pdb.python_fu_marvelmods_basic_get_path_save(image, layer)
I get a "RuntimeError: execution error" from Gimp. The second script so far only contains that line of code within its main function.
I have also tried putting the variables into a list within both scripts:
Code:
[folderName, fileName]
Modder/Skinner at MarvelMods.com using GIMP to create, edit, and export textures and previews more efficiently.
My GIMP scripts hosted on GitHub
My GIMP scripts hosted on GitHub