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?

Thanks

Chris

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

http://awalker.freeservers.com/Blender/script.html

-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.

Chris

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.

Chris

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:
Draw:
[‘ACCENTGRAVEKEY’, ‘AKEY’, ‘BACKSLASHKEY’, ‘BACKSPACEKEY’, ‘BKEY’,
‘Button’, ‘CAPSLOCKKEY’, ‘CKEY’, ‘COMMAKEY’, ‘Create’, ‘DELKEY’, ‘DKEY’,
‘DOWNARROWKEY’, ‘Draw’, ‘EIGHTKEY’, ‘EKEY’, ‘ENDKEY’, ‘EQUALKEY’, ‘ESCKEY’,
‘Exit’, ‘F10KEY’, ‘F11KEY’, ‘F12KEY’, ‘F1KEY’, ‘F2KEY’, ‘F3KEY’, ‘F4KEY’,
‘F5KEY’, ‘F6KEY’, ‘F7KEY’, ‘F8KEY’, ‘F9KEY’, ‘FIVEKEY’, ‘FKEY’, ‘FOURKEY’,
‘GKEY’, ‘HKEY’, ‘HOMEKEY’, ‘IKEY’, ‘INPUTCHANGE’, ‘INSERTKEY’, ‘JKEY’,
‘KEYBD’, ‘KKEY’, ‘LEFTALTKEY’, ‘LEFTARROWKEY’, ‘LEFTBRACKETKEY’,
‘LEFTCTRLKEY’, ‘LEFTMOUSE’, ‘LEFTSHIFTKEY’, ‘LINEFEEDKEY’, ‘LKEY’,
‘MIDDLEMOUSE’, ‘MINUSKEY’, ‘MKEY’, ‘MOUSEX’, ‘MOUSEY’, ‘Menu’, ‘NINEKEY’,
‘NKEY’, ‘Number’, ‘OKEY’, ‘ONEKEY’, ‘PAD0’, ‘PAD1’, ‘PAD2’, ‘PAD3’, ‘PAD4’,
‘PAD5’, ‘PAD6’, ‘PAD7’, ‘PAD8’, ‘PAD9’, ‘PADASTERKEY’, ‘PADENTER’,
‘PADMINUS’, ‘PADPERIOD’, ‘PADPLUSKEY’, ‘PADSLASHKEY’, ‘PAGEDOWNKEY’,
‘PAGEUPKEY’, ‘PAUSEKEY’, ‘PERIODKEY’, ‘PKEY’, ‘QFULL’, ‘QKEY’, ‘QUOTEKEY’,
‘Q_FIRSTTIME’, ‘RAWKEYBD’, ‘REDRAW’, ‘RETKEY’, ‘RIGHTALTKEY’,
‘RIGHTARROWKEY’, ‘RIGHTBRACKETKEY’, ‘RIGHTCTRLKEY’, ‘RIGHTMOUSE’,
‘RIGHTSHIFTKEY’, ‘RKEY’, ‘Redraw’, ‘Register’, ‘SEMICOLONKEY’, ‘SEVENKEY’,
‘SIXKEY’, ‘SKEY’, ‘SLASHKEY’, ‘SPACEKEY’, ‘Scrollbar’, ‘Slider’, ‘String’,
‘TABKEY’, ‘THREEKEY’, ‘TIMER0’, ‘TIMER1’, ‘TIMER2’, ‘TIMER3’, ‘TKEY’,
‘TWOKEY’, ‘Text’, ‘Toggle’, ‘UKEY’, ‘UPARROWKEY’, ‘VKEY’, ‘WINCLOSE’,
‘WINFREEZE’, ‘WINQUIT’, ‘WINTHAW’, ‘WKEY’, ‘XKEY’, ‘YKEY’, ‘ZEROKEY’,
‘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?

Chris

:wink:

Chris

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: