2

Comrades, I figured out how to open a .blend file using an separate/external Python script, I would now like to know how to send instructions to the Python Interactive Console? The code below is run from a simple Idle Python3.3 module. The commented line does not work - any suggestions on how to fix this? I want to call the Embedded Player to run automatically from another script.

import os

def openFile():
    try:
        os.startfile('bob2.blend')
        os.system('Python:bpy.ops.view3d.game_start()')#start embedded player??
    except Exception as e:
        print (e)

I am aware that making the .blend file a .exe will solve this problem but the will make development very slow as I will have to compile the BGE every time I change code... Thanks guys!

CubeBot88
  • 677
  • 2
  • 6
  • 17
  • Why don't you run the game engine in Blender by hitting P during the development? It has a decent text editor with syntax highlighting. – CodeManX Apr 16 '14 at 19:43
  • Thanks, but I am trying to implement a program that makes use of semaphores (running two program simultaneously), so I need the .blend file to run the embedded player intimidatingly. If you know how to send the command that is executed when 'P' is pressed then I can send that through the Python IDLE master script to the BGE's Embedded Player. Any ideas on how to do this? – CubeBot88 Apr 17 '14 at 06:44
  • See related question: http://blender.stackexchange.com/questions/41533 – ideasman42 Jan 22 '16 at 07:13

1 Answers1

2

If running the exe works, you could also open the blend with blenderplayer and not worry about exporting.

os.system('/path/to/blenderplayer.exe bob2.blend')
pqftgs
  • 496
  • 3
  • 9