Hi guys!
1. I need som good books/tutorials on Maya API! :(
2. I am setting up a node with 2 message input attributes (one for
connecting message from fluid and another from particle)
This is what I have in compute function def:
def compute(self, plug, dataBlock):
print "1. preparing"
result = "1. preparing"
connections = om.MPlugArray()
connection = om.MPlug()
plugParticleNode = om.MPlug()
plugParticleNode.setAttribute(self.particleNode) #this is the
connection to the message att
connectedToParticleNode = om.MObject()
plugFluidNode = om.MPlug()
plugFluidNode.setAttribute(self.fluidNode) #this is the
connection to the message att
connectedToFluidNode = om.MObject()
print "2.computed"
result = "2.computed"
# check if a particle is connected to the particleNode input
plugParticleNode.connectedTo(connections,1,0)
if (connections.length() > 0):
connection = connections[0]
connectedToParticleNode = connection.node()
try:
connectedParticleNode =
omFX.MFnParticleSystem(connectedToParticleNode) # I will be later
using function set to read particle atts
particleConnected = 1
except:
statusError("Not valid particle shape connected")
particleConnected = 0
else:
particleConnected = 0
print "3.particle checked with value %d" % particleConnected
result = "3.particle checked with value %d" %
particleConnected
# check if a fluid is connected to the fluidNode input
plugFluidNode.connectedTo(connections,1,0)
if (connections.length() > 0):
connection = connections[0]
connectedToFluidNode = connection.node()
try:
connectedFluidNode =
omFX.MFnFluid(connectedToFluidNode) # I will be later using function
set to read fluid atts
fluidConnected = 1
except:
statusError("Not valid fluid shape connected")
fluidConnected = 0
else:
fluidConnected = 0
print "4.fluid checked with value %d" % fluidConnected
result = "4.fluid checked with value %d" % fluidConnected
Problem:
1. I did not know how to construct the MPlug with function (MObject,
Attribute) (there is no thisObject() function in python API?) So I
just created it and then assigned
2. When I create the node, everything works. I get the correct integer
number for my debugging (0 for both). As soon as I connect anything to
those message atts, I get crash. Even without that, when I after
creation try to create new scene, I get crash. If I comment out the
connection checking functions, nothing crashes.
Btw...That's all I compute, nothing after this part of code except of
setting custom debugging attribute to the *result* value value.
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---