Home Technical Talk

maya python newbie question

Hello everyone - I was hoping I could ask for
some help loading a python script in maya. VERY SIMPLE question if you've done it before!!

The script is pretty simple and it runs well on other computers, so I
might just be missing a simple step. Supposedly, all that is
necessary is to load it in the python tab of the script editor and run
it. Then, I open the expression editor and type in:
python("MayaFluidtoGh()");

When I do this there is a warning in the expression editor that says:
"there is no expression to create"

Below is the script:

#Maya Fluid to Gh
##########################################################################
#this script export Fluid density via UDP
##########################################################################
#create the fluid in Maya, be sure that your fluid name is fluid1
#open the script editor and in Python load and run the script
#in the Expression write: python("MayaFluidtoGh()");
#choose create
##########################################################################
#Tommaso Casucci: http://synth-e-techmorph.blogspot.com/
##########################################################################

def MayaFluidtoGh():

import maya.cmds as cmds
import socket

UDP_IP="127.0.0.1"
UDP_PORT=7001

cmds.select ( 'fluid1')
dens = cmds.getFluidAttr( at='density')
MESSAGE = str(dens)


sock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
sock.sendto( MESSAGE, (UDP_IP, UDP_PORT) )
sock.close()

Replies

  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    That error suggests that there is no text in the expression pane when you clicked Create.

    Also be aware that in Python the indentation is part of the syntax so you should use the "Code" BB tags when quoting Python code on polycount to preserve it.
Sign In or Register to comment.