I stand corrected... thanks for the clarification!

- Paul

On Fri, Aug 21, 2009 at 11:09 AM, Chad Vernon<[email protected]> wrote:
> "Oh, and for future reference - if a c++ function declaration says it
> requires a "float*&" - or more generally, a "anything&" - you can
> pretty much ignore the '&' when dealing with the python side of things"
>
> Not exactly true.  Passing by reference for simple types like ints, floats,
> etc, you need to use MScriptUtil in Python.  If it's a non-simple type like
> an MFloatArray, then you can ignore it.  You need to use MScriptUtil for
> pointers and references to simple types.  This getColors function is tricky
> because it expects a reference to a pointer.  Maya treats references as
> pointers, so in this case, the function expects a  pointer to a pointer,
> which I don't think MScriptUtil supports so I think you're out of luck.
>
> It's also complaining about argument 2 in your implementation because the
> first argument in a python class is always self.
>
> Chad
>
> On Fri, Aug 21, 2009 at 9:06 AM, Paul Molodowitch <[email protected]>
> wrote:
>>
>> Hey Fabio -
>> I got some good news and some bad news.
>> Good news: I don't think you're doing anything wrong.
>> Bad news: ...but it just doesn't work.
>>
>> In other words, I think it's a bug with the python implementation of
>> this function. Can anybody else confirm? I tried:
>>
>> import maya.OpenMaya as om
>> import maya.OpenMayaFX as omfx
>> import maya.cmds as cmds
>>
>> fluidTransformName = cmds.createNode('transform')
>> fluidShapeName = cmds.createNode('fluidShape', parent=fluidTransformName)
>> # Need this, or the fluid shape doesn't register correctly when
>> # we try to call MFnFluid(...)
>> cmds.refresh()
>>
>> selList = om.MSelectionList()
>> selList.add(fluidShapeName)
>> dag = om.MDagPath()
>> selList.getDagPath(0, dag)
>> print dag.fullPathName()
>> selList.getDependNode(0, mobj)
>> fluidNode = omfx.MFnFluid(dag)
>>
>> ptrs = []
>> for i in xrange(3):
>>        ptrs.append(om.MScriptUtil().asFloatPtr())
>> fluidNode.getColors(*ptrs)
>>
>> ...and got the same error as Fabio.
>>
>> The thing here is that it's complaining about argument TWO - but
>> according to the docs, argument two is the exact same as argument
>> one... so if it worked for one, it SHOULD work for two.  So I'm pretty
>> sure it's a bug.
>>
>> Oh, and for future reference - if a c++ function declaration says it
>> requires a "float*&" - or more generally, a "anything&" - you can
>> pretty much ignore the '&' when dealing with the python side of things
>> (assuming the python wrapper has been implemented correctly).  The '&'
>> has more to do with how the function handles the argument within the
>> function than with what sort of thing you need to pass it when
>> invoking it.
>>
>> - Paul
>>
>>
>> On Thu, Aug 20, 2009 at 11:27 PM, holofermes<[email protected]> wrote:
>> >
>> > My eyes hurt!
>> > I really looked everywhere, and didn't find anything about how to pass
>> > this kind of argument.
>> > Please HELP!
>> > ///
>> >
>> > On Aug 19, 6:36 pm, holofermes <[email protected]> wrote:
>> >> Thanks!
>> >> That's what I needed! I'm getting there!
>> >> Now I'm running in a problem that I fear being big. MScriptUtil.
>> >>
>> >> the MFnFluid has a method getColors that as arguments needs 3 float
>> >> *&. As I was looking around the group, and in the web, I couldn't find
>> >> anything about passing a pointer and reference argument. If I pass it
>> >> as
>> >>
>> >> pointerMagic = om.MScriptUtil()
>> >> ptr = pointerMagic.asFloatPtr()
>> >> ptg = pointerMagic.asFloatPtr()
>> >> ptb = pointerMagic.asFloatPtr()
>> >>
>> >> the actual value that each float returns is:
>> >> # Result: _b0144915_p_float #
>> >>
>> >> but when I pass these values to getColors():
>> >>
>> >> fluidNode.getColors(ptr,ptg,ptb)
>> >>
>> >> it raises a TypeError:
>> >>
>> >> # TypeError: in method 'MFnFluid_getColors', argument 2 of type 'float
>> >> *&' #
>> >>
>> >> Question is:
>> >> Any possibilities of pasing a reference as an argument to the
>> >> function?
>> >>
>> >> Thanks!!!!!!!
>> >> /Fabio
>> >>
>> >> On Aug 19, 12:59 pm, Paul Molodowitch <[email protected]> wrote:
>> >>
>> >> > Ah - you're starting down the path of API programming there.  If you
>> >> > haven't already taken a look at them, the basic references to start
>> >> > are:
>> >>
>> >>
>> >> > >http://download.autodesk.com/us/maya/2009help/API/index.htmlhttp://do......
>> >>
>> >> > Also, robthebloke had a good site on stuff on the api - sadly, it
>> >> > died
>> >> > (go to robthebloke.org for a truly touching memorial)... - but
>> >> > happily, like a good horror movie sequel, it was brought back to life
>> >> > by Macey
>> >> > at:http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/
>> >>
>> >> > Also, a good book intro to the maya api
>> >> > is:http://www.amazon.com/Complete-Maya-Programming-Extensive-Kaufmann/dp...
>> >>
>> >> > Just to get you started: according to the maya docs
>> >> >
>> >> > (http://download.autodesk.com/us/maya/2009help/API/class_m_fn_fluid.html),
>> >> > MFnFluid can take EITHER an MObject or an MDagPath; in either case,
>> >> > the typical way to get access to one of these "from scratch" for us
>> >> > scripters is through the use of MSelectionList:
>> >>
>> >> > import maya.OpenMaya as om
>> >> > import maya.OpenMayaFX as omfx
>> >>
>> >> > selList = om.MSelectionList()
>> >> > selList.add("myFluidNodeName")
>> >> > dag = om.MDagPath()
>> >> > selList.getDagPath(0, dag)
>> >> > fluidNode = omfx.MFnFluid(dag)
>> >>
>> >> > Good luck!
>> >>
>> >> > - Paul
>> >>
>> >> > On Tue, Aug 18, 2009 at 5:54 PM, holofermes<[email protected]>
>> >> > wrote:
>> >>
>> >> > > Hi!
>> >> > > I'm a first-poster, but a long-time-reader, so first of all
>> >> > > compliments to all of you guys!
>> >> > > I'm a MEL - Python user, and I know very little about C/C++.
>> >> > > I was presented with a problem a day ago, where I would have to
>> >> > > extrapolate data of a fluid shape, such as color, density,
>> >> > > position,
>> >> > > and then bring them back to Houdini. Being able to read them in
>> >> > > Houdini won't be a problem (I hope). Being able to export them
>> >> > > quickly
>> >> > > it's givining me headachess.
>> >> > > I tried to use mel to export data, and it works fine, but it just
>> >> > > too
>> >> > > slow. So I started looking around and I found out that there has
>> >> > > been
>> >> > > already somebody working something out
>> >>
>> >> >
>> >> > > >http://groups.google.com/group/python_inside_maya/browse_thread/threa...
>> >>
>> >> > > and
>> >>
>> >> >
>> >> > > >http://groups.google.com/group/python_inside_maya/browse_thread/threa...
>> >>
>> >> > > I kind of understand how does it work, but I can't get it to work
>> >> > > my
>> >> > > self. I get stuck right at the beginning.
>> >>
>> >> > > Questions:
>> >>
>> >> > > fluidNode = OpenMayaFX.MFnFluid(node)
>> >>
>> >> > > What is node supposed to be?
>> >> > > MFnFluid is supposed to get a "MDagPath const &" type. How can I
>> >> > > get
>> >> > > "node" to become what MFnFluid wants?
>> >> > > I would like this to be working on a selection basis, so would the
>> >> > > "node" get a different parametrization?
>> >> > > I'm not sure what a MDagPath does as well.
>> >>
>> >> > > More to come
>> >>
>> >> > > Thanks,
>> >> > > Fabio.
>> >>
>> >>
>> > >
>> >
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to