Exporting to a VRML file via a Python Script

Hi Everyone,

I don’t know if this is even possible, I want loop throught all the frames in an animation and save each frame as a vrml file, much the same as going CTRL-F2 on each frame.

Is it possible to automate this in Python?



-There is a python wrl exporter(wrlexport.py).You can find it here:


-But it has to be modified to do what you want,because it exports only one frame.

Thanks for that I will check it out.


Hi I checked out the write wrlexport.py but unfortunately it does not do what I require. Is there anyway to call the CTRL+F2 vrml saver in a Python script.


There doesn’t appear to be any access to the Ctrl key in the python API (Publisher 2.25 OS X) this is the list of keys in Blender.Draw:
‘Button’, ‘CAPSLOCKKEY’, ‘CKEY’, ‘COMMAKEY’, ‘Create’, ‘DELKEY’, ‘DKEY’,
‘Exit’, ‘F10KEY’, ‘F11KEY’, ‘F12KEY’, ‘F1KEY’, ‘F2KEY’, ‘F3KEY’, ‘F4KEY’,
‘NKEY’, ‘Number’, ‘OKEY’, ‘ONEKEY’, ‘PAD0’, ‘PAD1’, ‘PAD2’, ‘PAD3’, ‘PAD4’,
‘SIXKEY’, ‘SKEY’, ‘SLASHKEY’, ‘SPACEKEY’, ‘Scrollbar’, ‘Slider’, ‘String’,
‘TWOKEY’, ‘Text’, ‘Toggle’, ‘UKEY’, ‘UPARROWKEY’, ‘VKEY’, ‘WINCLOSE’,
‘ZKEY’, ‘builtins’, ‘doc’, ‘file’, ‘name’] None
It may be accessable in the none OS X versions though. To find out if the version of Blender you’re using includes the Ctrl-key type the script in a text window (Blender text window) then alt-p

import Blender
a = dir(Blender.Draw)
print a

The output will be in the console window. If it’s not listed there is no access.

Thanks, I have tried you example and I get all the key names in the console window.

Is it possible to send these keystrokes to Blender?




P.S. I don’t think it’s possible to send key strokes via blender python
– I think these are used for when you set up a subroutine to handle
keystroke events in a python window.

Time for a cane and magnifying glass in my dotage, I still can’t see them :o

It’s possible, but you’ll need to know about some external modules. I only know that this is possible through windows, but you need the win32 Python extensions by Mark Hammond, which you already have if you are using the ActiveState distribution of Python.

If you’re familiar with Win32 programming, you can probably solve this problem the same way you would from C (use the win32 API to find the correct window handle and then send it the correct message. I don’t have any sample code to do this, but your Python code will follow the C equivalent almost call-for-call on the API level (the Python extensions are wrappers for the equivalent win32 calls so the names are usually very close, if not identical, to the originals).

Believe me, you’d need to know some pretty advanced techniques such as accessing the handle for Python and using an API call to simulate a keystroke. But best of luck :wink: