Notifications
Clear all

[Closed] How work with pipes in 3dsmax.exe -server mode

How to work with pipes in 3dsmax.exe -server mode
I try to do so:

run python file:


  import threading
  import win32pipe
  import win32file
  import pywintypes
  import winerror
  import win32event
  
  class MaxThread(threading.Thread):
  	def __init__(self, pipename):
  		self.pipename=pipename
  		threading.Thread.__init__(self)
  
  	def run(self):
  		print("%s START"%self.pipename)
  
  		pipeName = "\\\\.\\pipe\\%s"%self.pipename
  		openMode = win32pipe.PIPE_ACCESS_DUPLEX | win32file.FILE_FLAG_OVERLAPPED
  		pipeMode = win32pipe.PIPE_TYPE_MESSAGE
  
  		pipeHandle = win32pipe.CreateNamedPipe(pipeName, openMode, pipeMode, win32pipe.PIPE_UNLIMITED_INSTANCES, 65536, 65536, 6000, None)
  
  		hWaitStop = win32event.CreateEvent(None, 0, 0, None)
  
  		overlapped = pywintypes.OVERLAPPED()
  		overlapped.hEvent = win32event.CreateEvent(None,0,0,None)
  
  		error = None
  		while 1:
  			try:
  				hr = win32pipe.ConnectNamedPipe(pipeHandle, overlapped)
  			except error, details:
  				print "Error connecting pipe!", details
  				pipeHandle.Close()
  				break
  
  			if hr==winerror.ERROR_PIPE_CONNECTED:
  				win32event.SetEvent(overlapped.hEvent)
  
  			timeout = win32event.INFINITE
  			waitHandles = hWaitStop, overlapped.hEvent
  			rc = win32event.WaitForMultipleObjects(waitHandles, 0, timeout)
  
  			try:
  				hr, data = win32file.ReadFile(pipeHandle, 256)
  				print data
  				win32file.WriteFile(pipeHandle, "You sent me:" + data)
  				win32pipe.DisconnectNamedPipe(pipeHandle)
  			except win32file.error:
  				continue
  
  		print("%s END"%self.pipename)
  
  MaxThread("5024_43545183serverToMax").start()
  MaxThread("5024_43545183maxToServer").start()
  

pipelist.exe shows these pipes

Then run 3dsmax bat file “…\3dsmax.exe” -server “-_pipe:5024_43545183”

Then 3dsmax and python close with two exceptions:


  Exception in thread Thread-1:
  Traceback (most recent call last):
    File "C:\Python27\lib	hreading.py", line 551, in __bootstrap_inner
  	self.run()
    File "testpipe.py", line 37, in run
  	hr = win32pipe.ConnectNamedPipe(pipeHandle, overlapped)
  error: (232, 'ConnectNamedPipe', '....')
  
  Exception in thread Thread-2:
  Traceback (most recent call last):
    File "C:\Python27\lib	hreading.py", line 551, in __bootstrap_inner
  	self.run()
    File "testpipe.py", line 37, in run
  	hr = win32pipe.ConnectNamedPipe(pipeHandle, overlapped)
  error: (232, 'ConnectNamedPipe', '....')