Is it possible to force uncheck with python the "Relative Path" checkbox in the filebrowser?
2 Answers
$\begingroup$
$\endgroup$
2
You need not reinvent the wheel, you can use functions from menu File -> External data -> make all paths relative (absolute). The python code of this comands are:
bpy.ops.file.make_paths_relative()
bpy.ops.file.make_paths_absolute()
-
$\begingroup$ Thanks. It works well, however using this command causes an error when installing. $\endgroup$ Commented Sep 13, 2018 at 6:12
-
$\begingroup$ Accidental relative path when picking a file breaks Python's Pathlib module handling (especially if it is run as a callback) if your prop is a an actual file path chooser therefor this answer is totally useless. It does not answer the original question. $\endgroup$ Commented Oct 3, 2020 at 2:06
$\begingroup$
$\endgroup$
You can ensure that the path is absolute(which was what I needed to know back in the day) this way:
import bpy, os
path = bpy.context.scene.sequence_editor.active_strip.filepath
path = (os.path.realpath(bpy.path.abspath(path)))
File > External Data > Make All Paths Absolute
Than resetting the default of operators such asbpy.ops.image.open(relative_path=False)
$\endgroup$