I am currently working on project which needs to handle XODE files.
I was very happy pyODE provides interface for this, but I am a bit confused that "official" sample does not work.
I am running on Windows XP, Python 2.5 and pyODE 1.2 for this Python release.
When I execute this code from IDLE, I just get:
[console]
Traceback (most recent call last):
File "C:/Python25/Skola/ParseXODE.py", line 4, in <module>
p = parser.Parser(f)
TypeError: __init__() takes exactly 1 argument (2 given)
[/console]
So I removed the "f" parameter and left out empty brackets.
So we move on to error on next line:
[console]
Traceback (most recent call last):
File "C:/Python25/Skola/ParseXODE.py", line 5, in <module>
root = p.parseFile(f)
File "C:\Python25\Lib\site-packages\xode\parser.py", line 210, in parseFile
self._create().ParseFile(fp)
File "C:\Python25\Lib\site-packages\xode\body.py", line 127, in _startElement
raise errors.ChildError('body', name)
ChildError: <group> is not a valid child of <body>.
[/code]
... and I can't get error-free run of the script so far.
Could anybody suggest me (X)ODE dedicated Python site with more up to date information.
As I see sample script does not run I think something is wrong.
It is also a bit suspicious that as the script fails, file it tried to open remains locked until I shut down Python&IDLE
Thanks for any help, I am really Python/pyODE beginner so I probably miss something evident.
Best regards,
Petr
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
problem was in some typos in sample script, correct script listing follows:
[code]
from xode import parser
import ode
# Loads file and makes it ready to be parsed
# [!] Make sure file exists
f = file('xode-document.xml')
p = parser.Parser()
root = p.parseFile(f)
# Retrieve named objects
# [!] Make sure file really contains body1 and joint1
body1 = root.namedChild('body1').getODEObject()
joint1 = root.namedChild('joint1').getODEObject()
# Transverse the tree printing object names
def transverse(node):
print node.getName()
for c in node.getChildren():
transverse(c)
transverse(root)
[/code]
Best regards,
Petr
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am currently working on project which needs to handle XODE files.
I was very happy pyODE provides interface for this, but I am a bit confused that "official" sample does not work.
I am running on Windows XP, Python 2.5 and pyODE 1.2 for this Python release.
I tried to run sample from http://pyode.sourceforge.net/api-1.2.0/public/xode.parser-module.html
When I execute this code from IDLE, I just get:
[console]
Traceback (most recent call last):
File "C:/Python25/Skola/ParseXODE.py", line 4, in <module>
p = parser.Parser(f)
TypeError: __init__() takes exactly 1 argument (2 given)
[/console]
So I removed the "f" parameter and left out empty brackets.
So we move on to error on next line:
[console]
Traceback (most recent call last):
File "C:/Python25/Skola/ParseXODE.py", line 5, in <module>
root = p.parseFile(f)
File "C:\Python25\Lib\site-packages\xode\parser.py", line 210, in parseFile
self._create().ParseFile(fp)
File "C:\Python25\Lib\site-packages\xode\body.py", line 127, in _startElement
raise errors.ChildError('body', name)
ChildError: <group> is not a valid child of <body>.
[/code]
... now I am getting confused - the only files I use for tests are those from XODE website:
http://tanksoftware.com/xode/1.0r23/examples/
... and I can't get error-free run of the script so far.
Could anybody suggest me (X)ODE dedicated Python site with more up to date information.
As I see sample script does not run I think something is wrong.
It is also a bit suspicious that as the script fails, file it tried to open remains locked until I shut down Python&IDLE
Thanks for any help, I am really Python/pyODE beginner so I probably miss something evident.
Best regards,
Petr
Hi,
problem was in some typos in sample script, correct script listing follows:
[code]
from xode import parser
import ode
# Loads file and makes it ready to be parsed
# [!] Make sure file exists
f = file('xode-document.xml')
p = parser.Parser()
root = p.parseFile(f)
# Retrieve named objects
# [!] Make sure file really contains body1 and joint1
body1 = root.namedChild('body1').getODEObject()
joint1 = root.namedChild('joint1').getODEObject()
# Transverse the tree printing object names
def transverse(node):
print node.getName()
for c in node.getChildren():
transverse(c)
transverse(root)
[/code]
Best regards,
Petr