Hi I think I have a little problem with linking of objects.
I am quite new to both Python and Blender and what I have is a log file that has been generated by an other program (CD++, a DEVS toolkit) and want to visualize the results of the simulation by running a Python script.
My objects (passengers and obstacles) get displayed correctly initially, but as they are to move around they mostly disappear. What happens exactly is that the first time a “space” is occupied, a new object is created and linked to the current scene -> works fine. The except bit of script only gets executed if the object does not already exist. Please note that the objects don’t actually move but just appear and disappear and the positions corresponding the cells.
if logValue == -2: # Occupied cell (passenger) try: ob = Blender.Object.Get(objectname) # scn.objects.link(ob) logfile.write(" Object exist or linked ") except ValueError: human = Blender.Object.Get ('Human') human.select(1) Blender.Object.Duplicate() activeObject = scn.getActiveObject() activeObject.name = objectname activeObject.LocX = int(xcoord) activeObject.LocY = int(ycoord) activeObject.LocZ = int(zcoord) activeObject.select(0) logfile.write(" Object created ")
Then when the passenger is to move (or leave a cell, as the simulation is represented by cells) the passenger gets unlinked with the following chunk of script
elif logValue == 0: # Empty cell try: ob = Blender.Object.Get(objectname) scn.objects.unlink(ob) logfile.write(" Object unlinked ") except ValueError: logfile.write(" Cell already empty ") else: logfile.write(" **Log value not recognised as valid: %d** " %(logValue))
The second time an object is supposed to “appear” at a location that has been used before… Nothing happen. I mean the
ob = Blender.Object.Get(objectname)
executes without error but the object itself does not show in the scene.
Any help would be much appreciated, I have tried everything I can think of and looked on many forums but have not found any relevant info.