Isotropix Forums

load image path from python API

Clarisse Scripting related topics

load image path from python API

Unread postby tdsj4571 » Wed Apr 17, 2019 8:40 am

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.
tdsj4571
 
Posts: 6
Joined: Wed Apr 17, 2019 8:22 am

Re: load image path from python API

Unread postby bvaldes » Wed Apr 17, 2019 1:58 pm

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
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 384
Joined: Mon Sep 26, 2016 10:44 am

Re: load image path from python API

Unread postby tdsj4571 » Mon Apr 22, 2019 9:37 am

I'm sorry that answer to you late and thank you for your help!
I could solve the problem!
tdsj4571
 
Posts: 6
Joined: Wed Apr 17, 2019 8:22 am


Return to Scripting
cron