First of all, you don’t need the “iniciarlista” script, because “g.lista” is just a variable to which you can pretty much assign anything from the get go (I mean it’s python, almost anything goes). You don’t need a script to specify that it’s actually a list, before you assign a list to it. So I suggest you get rid of that whole thing.
Second, the python code spat out errors. I don’t know how you got it to do anything else, because you had spaces where they should not be (remember, python notes the whitespace as a delimiter), also I don’t think you need to use “append” here, just assign the list directly to “g.lista”. You can add stuff later to another list, or if you don’t use “g.lista” as an assigment variable (I will use it as such though) then you can probably do it your way too.
I made the following changes to the “nododetector” script:
if cerca.isPositive():
g.lista = cerca.getHitObjectList()
print g.lista
Now that returned no errors, but it did return a seemingly empty list “[, , ,]”. I’m just guessing at this point, but I think the whole “getHitObject” thing was not meant to return the actual “names” of the hit object, but rather to give you “access” to the hit object.
In other words; a way to get the hit objects “own”. I hope I’m explaining that right.
However, there is a way to get the names. I don’t think many people know about this (actually I just found it out), but when you ask for the name property, even if you have a property named “name”, the default return for “name” always seems to be the object name in format “OBName”.
So do this, and see what you get:
if cerca.isPositive():
g.lista = cerca.getHitObjectList()
count = len(g.lista)
for i in range(count):
print g.lista<i>.name
Pretty nifty. I don’t know if this is documented ([I]looks more like a backward hack to me), but I could not find it mentioned in the docs. If anyone has any info on that I would appreciate it (is there 2 sets of python docs maybe? I get the feeling I’m missing some key things)
Well, anyway, hope this helps you out POCHO.
PS: O, and I almost forgot to mention: The object list doesn’t seem to be generated in a consistant order, so I don’t recommend using the order of the returned names to determine what’s closer or farther away from the scaning object.