Previous Thread  Next Thread

chat icon stdout.readline() works in Python but not in Blender

heskn

Posted: Sat Oct 06, 2012 9:00 am
Joined: 06 Oct 2012
Posts: 2
Quote:
import subprocess

NvTriStripPath = "C:/NvTriStripper-cli.exe"
vert_indices = [ 0, 1, 2, 1, 3, 2 ]

# Stripifying mesh
NvTriStrip = subprocess.Popen([NvTriStripPath],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE)

for vi in vert_indices: NvTriStrip.stdin.write(str(vi).encode() + " ".encode())

NvTriStrip.stdin.write("-1\n".encode())

print("STEP 1")
mashit = NvTriStrip.stdout.readline()
print("STEP 2")

stripcount = int(mashit)
if stripcount < 1: raise Exception("NvTriStrip returned 0 strips. Aborting")

nativelist = []
striptype = int(NvTriStrip.stdout.readline())
nativelength = int(NvTriStrip.stdout.readline())
nativelist.extend(map(int, NvTriStrip.stdout.readline().split()))

print(nativelist)

the above script works perfectly in python. the output is:
Code:
STEP 1
STEP 2
[0, 1, 2, 3]

but when i try to run it in blender if freezes the main window, and the last line in console window is:
Code:
STEP_1

NvTriStripper-cli.exe is in the root of the disk C:\

please help...
Reply with quote


CoDEmanX

Posted: Sat Oct 06, 2012 7:34 pm
Joined: 05 Apr 2009
Posts: 680
it's not intended to use a console beside Blender's interface...

but if you open Blender's console window, you should be able to use

os.read() and input()

sys.stdout.readline() gives me error:
io.UnsupportedOperation: not readable
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


stiv

Posted: Sat Oct 06, 2012 8:57 pm
Joined: 05 Aug 2003
Posts: 3485
No idea what your exe is doing, but you might try putting in a flush after the write, just in case blender is still waiting on the I/O to finish.
Reply with quote


heskn

Posted: Wed Oct 10, 2012 10:30 am
Joined: 06 Oct 2012
Posts: 2
thank you guys for your replies. thanks god the flush() thing managed the thing - now i can create triangle strips without rewriting old 2.49 scripts Smile
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group