VRED 2024, cancel sequenz rendering, python plugin

VRED 2024, cancel sequenz rendering, python plugin

andreasK3K4G
Enthusiast Enthusiast
332 Views
2 Replies
Message 1 of 3

VRED 2024, cancel sequenz rendering, python plugin

andreasK3K4G
Enthusiast
Enthusiast

Hi,

i have a plugin where the user can arange several variantset and viewports to render everything at once.
I am using vrAEBase class and put  the vrMovieExport.createSnapshot in a for loop. (f.e. for each viewpoint)
When the rendering starts, for sure the user can cancel the actual image rendered, via the render dialog which is displayed. (with the progress bar) But i want to be able to break/stop the whole for loop.

I tried to cancel the loop with a Key pressed event, but it is not working, no way to interrupt.

 

I have this class:

class prova(vrAEBase.vrAEBase):
    
    def __init__(self):
        
        super(prova, self).__init__()
        
        self.addLoop()
        
        self.keyQ = vrKey.vrKey(vrController.Key_W)
        self.keyQ.connect(lambda: self.test())
        
        self.counter = 0
        
        
    def loop(self):
        
        for i in range(1000000):
            self.j = i
            
            if self.j == 400:
                print(self.j)
                vrMovieExport.createSnapshot("C:/Users/AXIGHXP/Projects/test/render_sky/test" + str(self.counter) + ".png",500,500,1,0)
                self.counter += 1

    
    def test(self):
        print("EXIT")
        self.subLoop()

If i comment line 22, so not rendering, i can break the loop.

I guess because when starting the rendering, and the render dialog (with the progress bar) is display, the focus is lost for the key event, and there is no time in between the renderings to get the focus back.

 

When the user hit the cancel button on the render dialog, a message in the console is displayed.
"Rendering canceled".

Maybe i can grab this message/signal in my code to stop the loop? Would be ok, if the user just cancel one rendering, that all the progress is stoped then.

 

Best regards

Andreas

0 Likes
333 Views
2 Replies
Replies (2)
Message 2 of 3

clemens_schlicker_audi
Enthusiast
Enthusiast

You could check if the rendered image appeared at the specified directory. If the user canceled the process, there won't be an image.

A few issues with this approach:

  • images might appear with names that differ from the given full path (e.g. when rendering with renderpasses?) -> reverse-engineer VRED's filename composition and use the composed name when checking against existing files
  • if a given file already exists and has to be overwritten, the condition will always be met and the loop won't be cancelled -> Extra logic required (e.g. deleting previous file through code on purpose)
0 Likes
Message 3 of 3

andreasK3K4G
Enthusiast
Enthusiast

Hi Clemens,

thanks for the workaround, this works for me.

I can search for imagename + wildcard, so also with renderpasses i can check the file exists.

For the second concern, no problem, i will not allow the user to start the rendering if there are already the same

files with sequenz (names) in the choosen folder.
As a second approach, i can check the timestamps of the render start and the file created.