WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 08-14-2020, 05:08 AM
jericson jericson is offline
Registered User
Join Date: Aug 2020
Posts: 1
Using viz.window.screenCapture in a loop?

Hello, I'm having trouble using viz.window.screenCapture() to grab images before and after a list of objects have been removed from a scene. This short example is analogous to what I'm trying to do:

def showDebugBall(x,y,z,size=1):
	ball = viz.add('ball.wrl')

	smallball = viz.add('ball.wrl')
	return ball

objects = []
n = 12
for i in range(n):
	aball = showDebugBall(0,2,i)


for obj in objects:
If I run this code as is, the Before and After images show only a ground and sky plane, but no objects.

If I comment out the loop that removes the objs and also comment out the "After.png" screenCapture line, I get a "Before.png" that includes the objects, as expected.

It looks like there's a note about viz.window.screenCapture in the documentation: "Note: The image is not generated immediately. Vizard must wait until the next frame is rendered before it can capture the image." But I'm not sure how to modify the code based on this info.
Reply With Quote
Old 08-14-2020, 06:57 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
Here's an example using a task function that should capture an object before and after removing it:

import viz
import viztask


dojo = viz.addChild('dojo.osgb')
ball = viz.addChild('beachball.osgb', pos=[0,1.8,2])

def screenCaptureTask():
	yield viztask.waitFrame(1)

viztask.schedule( screenCaptureTask() )
Reply With Quote

remove objects, saving, screen capture, screenshots, viz.window.screencapture

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling vizard functions in a loop omidbrb Vizard 1 09-23-2009 09:19 AM
screenshots using a loop krimble Vizard 2 09-14-2009 02:20 AM
Creating a loop to switch between menu pages RodRSpv Vizard 1 03-02-2009 02:19 PM
For Loop in Callbacks? DrunkenBrit Vizard 2 02-19-2009 12:26 AM
for loop concatenation for 300 billboarding trees eugcc Vizard 4 04-22-2004 12:46 AM

All times are GMT -7. The time now is 10:35 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC