cubes with a certain property positions

Is there a way to list the positions of all cubes with a particular property?

I suggest you practice some Python programming skills - You will be able to answer this yourself!


def find_with_prop(obj, prop_name):
    return [o for o in obj.scene.objects if prop_name in o]

Your pyhon code does not print the positions of cubes with a certain property to the console.

Pineapple

Try printing what the function returns, and really, learn programming…

This shows all the positions of the scene objects.So i guess i am half way there.

import bge
sce = bge.logic.getCurrentScene()
print("Scene Objects:", sce.name)
for ob in sce.objects:
        print("   ", ob, "prop_name", ob.worldPosition)

@Lostscience

For cubes specifically you first need a way to identify those cubes. For example checking if something has 8 vertex, 6 planes and 3 pairs of opeosed normals each one perpendicular of one of the 3 axis. With that you would identify square pisms, to check if it’s a cube you could check that the area of each face is the same.

And of course, to do all that, learn Python. More acurately check the MeshProxy API: https://www.blender.org/api/blender_python_api_2_78a_release/bge.types.KX_MeshProxy.html

And now I realize that though I’ve answared what you asked, you probably didn’t ask what you wanted.


import bge
sce = bge.logic.getCurrentScene()
print("Scene Objects:", sce.name)
for ob in sce.objects:
        if "propertyName" in ob: print("   ", ob, "prop_name", ob.worldPosition)

Thankyou very much.Now i need to find out how to put those in a list.I will look online and see if i can figure it out and look in script examples that come with blender.

The script examples that come with blender are mainly for BPY, so they are useless for the game engine. To make a list for that either use:


import bge
sce = bge.logic.getCurrentScene()
l = list()
for ob in sce.objects:
        if "Property" in ob: l.append(ob.worldPosition)

Or a compression list, wich is what agose did:


l = [o.worldPosition for o in bge.logic.getCurrentScene().objects if "Property" in o]

I mean game logic simple and others.