Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Struffel

Pages: [1]

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():

Pages: [1]