Author Topic: Dynamically relocating resources (bitmaps)  (Read 297 times)


I am currently trying to write a script that automatically loads a set of bitmaps (which will ultimately be a PBR material that gets fed into a PBR render node) as bitmap resources. The incoming set of bitmaps should replace the existing resource objects. As a first goal I am trying to relocate all resources to use a file called "A.png". In the GUI I can simply type in a new filename in the properties section but once I try it via the API I get a "DataIsReadOnly" error, so that is apparently not the intended way? How does relocating resources/bitmaps work with the API?

Here is the current code which produces the error:
Code: [Select]
import sd
from import *
from sd.api.sdresourcebitmap import *
from sd.api.sdproperty import *
from sd.api.sdvaluestring import *

def initializeSDPlugin():
# setup
sd_context = sd.getContext()
sd_application = sd_context.getSDApplication()
sd_pkg_mgr = sd_application.getPackageMgr()
sd_ui_mgr = sd_application.getQtForPythonUIMgr()
sd_cat_annotation = SDPropertyCategory.Annotation

# get resources
sd_res = sd_pkg_mgr.getUserPackages()[0].getChildrenResources(True) #assuming that only one package is open
sd_img = []
for r in sd_res:
if(type(r) is sd.api.sdresourcebitmap.SDResourceBitmap):

# update file path
for i in sd_img:
i_file_path_prop = i.getPropertyFromId('file_path',sd_cat_annotation)
i_new_file_path = SDValueString.sNew("E:/A.png")

def uninitializeSDPlugin():


It is not currently possible to update a resource file path using the Python API. It is a limitation of the API.
I don't have any suggestions for possible alternatives. Maybe using symbolic links at the OS level could work?