Check for collision outside of Game Engine

I have written a script that creates a randoms series of rectangular objects within a defined envelope with help from others on weighting the random part. It works great, however, I want to be able to check if the next randomly generated part physically interferes with the current indexed part previously created. If yes, I want it to try again. Can I use the physics engine collision detection capabilities through Python or some other routine? Here is my code so far (you have to have an original part to select to start the random generation process):

import Blender
from Blender import Mathutils, Noise
from Blender.Mathutils import *

scn = Blender.Scene.GetCurrent()
ob_act = scn.objects.active
conv = 6.283185307179586476/360

Unselect all

scn.objects.selected = []
ob_act.sel = 1

for x in xrange(50):
Blender.Object.Duplicate() # Duplicate linked
ob_act = scn.objects.active

beamsize = int(Rand(1, 4)) Replaced with weighted random range below:

f = Noise.random()
if f < 0.75: beamsize = 1
elif f < 0.93: beamsize = 2
elif f < 0.98: beamsize = 3
else: beamsize = 4
print beamsize
if beamsize == 1:
    ob_act.setSize(1.0, 1.0, 1.0)
    yaw = Rand(5.0*conv, 175*conv)
    pitch = Rand(-11.0*conv, 11.0*conv)
elif beamsize == 2:
    ob_act.setSize(1.25, 1.0, 1.0)
    yaw = Rand(35.0*conv, 145.0*conv)
    pitch = Rand(-10.0*conv, 10.0*conv)
elif beamsize == 3:
    ob_act.setSize(1.5, 1.0, 1.0)
    yaw = Rand(49.0*conv, 131.0*conv)
    pitch = Rand(-9.0*conv, 9.0*conv)
elif beamsize == 4:
    ob_act.setSize(1.75, 1.0, 1.0)
    yaw = Rand(56.0*conv, 124.0*conv)
    pitch = Rand(-8.0*conv, 8.0*conv)
height = Rand(0.0, 7.0)
ob_act.LocZ = height
ob_act.LocY += int(Rand(14.0, 32.0))
ob_act.RotZ = yaw
ob_act.RotY = pitch
yaw = 0
pitch = 0
height = 0

Blender.Redraw()I don’t mean to cross post, but I don’t know how to remove it from the Python section of the forums. I realized a game engine guru would probably be able to help. Thanks.

Rob

It’s code like this that makes me happy! However, a randomly generated object cannont be tested before the game engine generates it. I had an idea though that might work, if your RGO’s are duplicates of other collision objects then that means you would be fine even if you didn’t script with python. This is just a guess, so don’t quote me on it. Best of luck.

This code made me happy once, not anymore. If I make my seed object that I am duplicating and transforming a collision object, you are saying it might take care of itself? Also this script is not using the BGE. I would like to use the BGE or the Bullet BGE API to do what I have stated. Any ideas? Thanks.

Rob