render.ls is a ghost command?

Hello All,

I’m unable to catch the result of render.ls() in a variable.
Is it normal?*

This would be really usefull to have it like a string buffer or something like this.

Yes I think thats absolut normal.
ls just print on the screen/stdout it has no return value.
Thats from the 1.1.0 reference:

ls
void PandaNode::ls(ostream &out, int indent_level) const;

Description: Lists all the nodes at and below the current path hierarchically.

I’m wondering why it doesn’t produce an error if you try to store nothing.

Martin

render.ls() sends its output via something like “print”, so you can’t catch its output. But you can do something like this:

lsb = LineStream()
render.ls(lsb)
text = ''
while lsb.isTextAvailable():
    text += lsb.getLine() + '\n'

The LineStream class is a Panda3D class that inherits from C++ ostream, so can be used in ls() or any other C++ method that requires an ostream; and then its contents can be extracted via a loop like the above.

David