How to use "cancelled" parameter of the render() function in python

How to use "cancelled" parameter of the render() function in python

LoganAC34
Advocate Advocate
1,198 Views
2 Replies
Message 1 of 3

How to use "cancelled" parameter of the render() function in python

LoganAC34
Advocate
Advocate

Hi, I'm trying to figure out how to use "cancelled" function of the render() function in python. I'm referencing these docs, trying to convert the function to python, but having issues getting it to work.

 

https://help.autodesk.com/view/MAXDEV/2023/ENU/?guid=GUID-9175301C-13E6-488B-ABA6-D27CD804B205#:~:te...

 

Here is the simplified code that i'm having issue with:

from pymxs import runtime as rt
render_canceled = False
r = rt.render(
   camera=camera,
   frame=frame,
   outputwidth=resolution,
   pixelaspect=pixel_aspect,
   outputfile=outputfile,
   vfb=False,
   progressbar=False,
   cancelled = render_canceled, # Cant figure out how to use in python
   to=rt.Bitmap(1, 1)
)

 

I have everything working except for the "cancelled" parameter. If i comment that out, everything works fine, but i'd like to get that working. If I uncomment it, i get the error below when run. 

 

 

r = rt.render(
    ^^^^^^^^^^
RuntimeError: MAXScript exception raised.
-- Unable to convert: false to type: &-reference

 

 

I don't know enough about python or Maxscript to know what it means, but my guess is that it has to do with a conflict between how python and maxscript work internally. It seems Maxscript needs a variable reference to write a True/False value to, but python is providing a value (False) instead of the variable reference. I don't know how in python (or if it's even possible) to provide the variable reference instead. 


Does anyone know how to get this working? Thanks!

0 Likes
Accepted solutions (1)
1,199 Views
2 Replies
Replies (2)
Message 3 of 3

LoganAC34
Advocate
Advocate

This is perfect!! I didn't find that in my research. I got it working! Thank you!!

from pymxs import runtime as rt
r, canceled = rt.render(
camera=camera,
frame=frame,
outputwidth=outputwidth,
outputheight=outputheight,
pixelaspect=pixel_aspect,
outputfile=outputfile,
vfb=False,
progressbar=False,
cancelled=pymxs.byref(None),
to=rt.Bitmap(1, 1)
)

 

0 Likes