Example #1
0
def serve(port=8000):
    ''' Launches the server on the specified port. '''
    autodesk.write_line('Opening connection at on port ' + str(port))
    httpd = SocketServer.TCPServer(("", port), Handler)
    httpd.timeout = 0.5
    try:
        while not Handler.shutting_down:
            httpd.handle_request()
            autodesk.app.process_tasks()
    finally:
        autodesk.write_line('Shutting down server')
        httpd.server_close()
Example #2
0
def serve(port=8000):
    ''' Launches the server on the specified port. '''
    autodesk.write_line('Opening connection at on port ' + str(port))        
    httpd = SocketServer.TCPServer(("", port), Handler)    
    httpd.timeout = 0.5
    try:
        while not Handler.shutting_down:
            httpd.handle_request()
            autodesk.app.process_tasks()
    finally:
        autodesk.write_line('Shutting down server')
        httpd.server_close()
Example #3
0
    def do_GET(self):
        ''' Respond to a "GET" request.  '''
        try:
            autodesk.write_line('GET request: ' + self.path)

            # Send headers, but abort if not successful.
            if not self.send_headers():
                return

            # Shut down the web server
            if '/exit' == self.path:
                Handler.shutting_down = True
                self.wfile.write('shutting down web server')

            # Return a JSON representation of the scene (without meshes) in the response.
            elif '/scene' == self.path:
                self.wfile.write(autodesk.scene_json())

            # Return the product name in the response.
            elif '/test' == self.path:
                self.wfile.write("This is a test. You are running " +
                                 autodesk.app.product)

            # Return a tree representation of the scene in the response.
            elif '/tree' == self.path:
                autodesk.output_scene_tree(self.wfile)

            # Return a JSON representation of the mesh of the first selected object.
            elif '/mesh' == self.path:
                self.wfile.write(autodesk.selected_mesh_json())

            # Echo the query request.
            else:
                self.wfile.write(self.path)
        except:
            self.wfile.write('Error occured')
            Handler.shutting_down = True
Example #4
0
    def do_GET(self):
        ''' Respond to a "GET" request.  '''
        try:
            autodesk.write_line('GET request: ' + self.path)

            # Send headers, but abort if not successful.
            if not self.send_headers():
                return                        

            # Shut down the web server 
            if '/exit' == self.path:
                Handler.shutting_down = True
                self.wfile.write('shutting down web server')            
            
            # Return a JSON representation of the scene (without meshes) in the response.
            elif '/scene' == self.path:
                self.wfile.write(autodesk.scene_json())

            # Return the product name in the response. 
            elif '/test' == self.path:
                self.wfile.write("This is a test. You are running " + autodesk.app.product)

            # Return a tree representation of the scene in the response.
            elif '/tree' == self.path:
                autodesk.output_scene_tree(self.wfile)

            # Return a JSON representation of the mesh of the first selected object. 
            elif '/mesh' == self.path:
                self.wfile.write(autodesk.selected_mesh_json())

            # Echo the query request. 
            else:
                self.wfile.write(self.path)          
        except:
            self.wfile.write('Error occured')
            Handler.shutting_down = True            
Example #5
0
def say_hello(s):
    autodesk.write_line("Hello")
Example #6
0
def say_hello(s):
    autodesk.write_line("Hello")
Example #7
0
def log(s):
    ''' Outputs a string to the application's console '''
    autodesk.write_line(s)
import autodesk 
autodesk.write_line(autodesk.selected_mesh_json())
Example #9
0
                autodesk.output_scene_tree(self.wfile)
            elif '/mesh' == self.path:
                self.wfile.write(autodesk.selected_mesh_json())
            else:
                self.wfile.write(self.path)          
        except:
            Handler.shutting_down = True            
                        
def ServeContent():
    httpd = SocketServer.TCPServer(("", 8000), Handler)
    while not Handler.shutting_down:
        httpd.handle_request()

ServeContent()

'''
autodesk.write_line("Testing")

autodesk.write_line("Root node: " + autodesk.root().name)

f = StringIO.StringIO()
autodesk.output_scene_tree(f)
autodesk.write_line(f.getvalue())

s = autodesk.scene_json_data()
autodesk.write_line(s)

for n in autodesk.root().tree:
    if n.selected:
        autodesk.write_line("Selected node: " + n.name)
'''
Example #10
0
def output_node(n, s=''):
    autodesk.write_line(s + n.name)
    for n2 in n.children:
        output_node(n2, s + '  ')
Example #11
0
def output_node(n, s=''):
    autodesk.write_line(s + n.name)
    for n2 in n.children:
        output_node(n2, s + '  ')
Example #12
0
import autodesk
autodesk.write_line(autodesk.selected_mesh_json())