Placing copy of objects via python

Let say we have some predefined objects in a scene: A cube, a sphere, a cylinder, a cone and a suzanne. We have also a predefined big pink plane, sort of a table.

I need to place a copy of one or more of this objects, at the start of the game engine, at random coordinates over the pink plane, based on a list like this:

examplelist = [[‘Cube’, ‘A box’], [‘Cone’, ‘An ice cream?’], [‘Cube’, ‘Hello world!’]]

Over every object is needed to place a text containing the string associated in the list.

It is possible?

Can you help me?

I have made an example ready to edit with the elements, it is attached.

availableobjects = Cube, Sphere, Cylinder, Cone, Suzanne
examplelist = [['Cube', 'A box'], ['Cone', 'An ice cream?'], ['Cube', 'Hello world!']]
for x in examplelist:
	place a copy of the corresponding object in the pink plane
	    at random location
	put a text over the new object containg the specified string


test.blend (198 KB)

I dont know if my question has a very simple answer, like one or two line of code, or if is a very complex task or impossible. Maybe at least someone can tell me if it is possible. I searched all over the internet for days without the results I hoped, I learned some other trick, but…

for my own game enemies spawn at random place, i did Empty with IPO - the empty allways moves in the area. and when i want, i press a key and make a enemie spawn. so i dont know in which place is the empty, becouse it is moving fast in whole area allways, so enemies appears anywhere.
but it just cheap trick :smiley:

Hi Mansim, thank for your contribute :slight_smile:
I think your system is very smart for respawning enemies in a game.
What I looking for is different however. In the work I have to accomplish the list of objects to place on the plane can be very big, to thousands of elements. Because of this your trick is not a solution for my problem. Thanks, in any case.

Well, this forum was my last hope. I think I have to spend more time learning hard for being capable of answering my question. Thanks in any case :frowning:

I will post you a blend file tonight.Do you want to spawn all objects in the list?

I think this will work. I dont have any time now to make something better. If you want i can make something later , just PM me.


random spawn point.blend (260 KB)

Hi Josip, you solved my problem! Thanks, now Im trying to understand and use your example. Ill post my little experiments results here soon.
I really want to make you know how I appreciate your contribute, I hope to become good at blender and python as you.

hehe i am just learning python , you are free to join me in my journey. If you need any help just ask.