oops...data() if for the datablock.  With plugs, use plug.asMObject()

On Tue, Aug 11, 2009 at 5:56 PM, Ozgur Yılmaz <[email protected]> wrote:

> thanks for your quick answer Chad,
>
> but unfortunately maya crashes by saying
>
> // Error: 'MPlug' object has no attribute 'data'
>
> by the way I screen captured Maya to get this error message, how do you
> guys debug your code with maya, I couldn't make it write some log messages
> while crashing...
>
>
> On Tue, Aug 11, 2009 at 6:22 PM, Chad Vernon <[email protected]> wrote:
>
>> Use MFnVectorArrayData
>>
>> oData = plug.data()
>> fnData = OpenMaya.MFnVectorArrayData(oData)
>> vectorArray = fnData.array()
>>
>> Any none simple types like matrix arrays, point arrays, vector arrays,
>> double arrays, etc, have a corresponding MFn*Data class.
>>
>> Chad
>>
>>
>> On Tue, Aug 11, 2009 at 5:16 AM, Ozgur <[email protected]> wrote:
>>
>>>
>>> I'm trying to write an MPxLocatorNode which uses an MVectorArray
>>> attribute to hold some data that it needs to use while drawing the
>>> shape of the locator, I mean the shape of the locator depends on to
>>> the data inside this attribute...
>>>
>>> My problem is the draw method doesn't have access to dataBlock which
>>> is only valid through compute method, so I need to figure out some way
>>> to access the MVectorArray without using the dataBlock, for simple
>>> variables like float, int, MDistance etc. I can use the MPlug derived
>>> from thisMObject like:
>>>
>>> thisNode = self.thisMObject()
>>> plug = OpenMaya.MPlug( thisNode, self.aTPos ) # aTPos is the attribute
>>> someFloat = plug.asFloat()
>>> someInt = plug.asInt()
>>> someDistance = plug.asMDistance()
>>>
>>> etc...
>>>
>>> but I can't get an MVectorArray this way...
>>>
>>> I tried to store the data in a class variable in compute, because it
>>> doesn't run the compute() as it tries to draw it, it didn't work...
>>>
>>> So, any idea ???
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> E.Ozgur Yilmaz
> Senior Technical Director
> www.ozgurfx.com
>
>
> >
>

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

Reply via email to