Page 1 of 1

load image path from python API

Unread postPosted: Wed Apr 17, 2019 8:40 am
by tdsj4571
Hi

People decided clarisse use here and then I begin making work environment for artists.
I have a problem for connection with renderfarm and clarisse by muster.
To connect with the elements, muster just needs image path and output path.
If users take render job without two paths, muster can't execute batch render job.
the job is executed from only one node in the farm management tool.

So, I tried to load them by python API from project file but I can't.
Don't you have anything for loading the paths inside python??

now I completed a script for rendering but it has bad codes and the project files are read line by line.
I'm worried about this making heavy render job.

Re: load image path from python API

Unread postPosted: Wed Apr 17, 2019 1:58 pm
by bvaldes
Hi,

Usually by launching cnode with the project file, if you checked render_to_disk attribute in your image/layer and set an output path, everything should work perfectly.

If I've understood your issue, it's that you have to specify by yourself the image and the output to Muster. For that there is an argument with Cnode: -info.
That will print out a xml file that will describe your project:
Code: Select all
<project>
  <filename>C:/Users/bvaldes/Desktop/my_awesome_project.project</filename>
  <version>1.0</version>
  <dependencies>
    <file>path_to_my_wonderful_geometry.abc</file>
  </dependencies>
  <image>
    <name>project://scene/image</name>
    <output>my_output</output>
    <format>exr16</format>
    <save_to_disk>1</save_to_disk>
    <start_frame>0</start_frame>
    <end_frame>50</end_frame>
    <frame_step>1</frame_step>
    <LUT>linear</LUT>
    <layer>
      <name>project://scene/image.background</name>
      <output></output>
      <format>exr16</format>
      <save_to_disk>0</save_to_disk>
      <start_frame>0</start_frame>
      <end_frame>50</end_frame>
      <frame_step>1</frame_step>
      <LUT>linear</LUT>
    </layer>
  </image>
  <settings>
    <fps>24</fps>
    <motion_blur_sample>3</motion_blur_sample>
    <motion_blur_direction>centered</motion_blur_direction>
    <motion_blur_length>50</motion_blur_length>
    <texture_cache>4096</texture_cache>
  </settings>
</project>


As this is XML, you can with python find the image and the output. You can find bellow an example of script:

python code

from xml.etree import ElementTree as ET
log = """<project>
<filename>C:/Users/bvaldes/Desktop/my_awesome_project.project</filename>
<version>1.0</version>
<dependencies>
<file>path_to_my_wonderful_geometry.abc</file>
</dependencies>
<image>
<name>project://scene/image</name>
<output>my_output</output>
<format>exr16</format>
<save_to_disk>1</save_to_disk>
<start_frame>0</start_frame>
<end_frame>50</end_frame>
<frame_step>1</frame_step>
<LUT>linear</LUT>
<layer>
<name>project://scene/image.background</name>
<output></output>
<format>exr16</format>
<save_to_disk>0</save_to_disk>
<start_frame>0</start_frame>
<end_frame>50</end_frame>
<frame_step>1</frame_step>
<LUT>linear</LUT>
</layer>
</image>
<settings>
<fps>24</fps>
<motion_blur_sample>3</motion_blur_sample>
<motion_blur_direction>centered</motion_blur_direction>
<motion_blur_length>50</motion_blur_length>
<texture_cache>4096</texture_cache>
</settings>
</project>"""

images = {}
xmlproject = ET.fromstring(log)
image_nodes = xmlproject.findall('image')
for img in image_nodes:
img_name = img.find('./name').text # get the path of the image
img_output = img.find('./output').text # get the output content
save_to_disk_node = img.find("./save_to_disk") # get the seve_to_disk content (1 it's enabled, 0 it's not)
if save_to_disk_node != None and save_to_disk_node.text == "1":
images[img_name] = img_output
print images


I hope this is what you need.
Best regards

Re: load image path from python API

Unread postPosted: Mon Apr 22, 2019 9:37 am
by tdsj4571
I'm sorry that answer to you late and thank you for your help!
I could solve the problem!