Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Subject: Cameras
Subject: scaleDown command
Subject: black out solved
Subject: Aircraft Tutorial
Subject: Mathematical XYZ ?
Subject: Re: Its done This vs That
Subject: Re: Its done first week
recommendations for screen video captures?
Subject: 3DExplorer "Oddity "
Subject: Re: New Director
Subject: ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
Subject: RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Subject: Re: Texturing
Big Break Contest Videos
Subject: New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Subject: Plasma?
Looking for Inspiration
Subject: Weird EMail Q
Subject: Re: It 's done first week ?
Subject: Cherry not cranberry
Subject: Re: New game
Camera Animation Problem
Subject: Particle plugins?
 
Subject: MArrayDataBuilder madness

Subject: MArrayDataBuilder madness

2003-12-08       - By Rich Pickler

 Back
I have a nasty problem with MArrayDataBuilder's that I've been going
'round and 'round with maya support to no avail.  Essentially, I need a
2D array of output string attributes, and I would rather use a
combination of an array compound attribute and a child array typed
attribute so I can address them individually from mel.  Also, I would
like to allow this addressing from expressions, so that pretty much
rules out using a typed attribute of MFnData::kStringArray and set that
to an array.  If I do that, I have to write a MPxCommand to parse the
output attribute, and I might as well do a custom data type at that point.

Anyways, so here's what I have:

// ::initialize snip

         MFnTypedAttribute fnColumns;
         columns = fnColumns.create( "columns", "cls",
                         MFnData::kString,
                         MObject::kNullObj,
                         &status );
         MCHECKERROR( status, "Cannot create columns attribute" );
         status = fnColumns.setArray( true );
         MCHECKERROR( status, "Cannot set columns to array" );
         status = fnColumns.setUsesArrayDataBuilder( true );
         MCHECKERROR( status, "Cannot set columns to builder" );
         // this has to be created and added before I can parent it to rows
         status = addAttribute( MODBCQuery::columns );
         MCHECKERROR( status, "Cannot add columns attr" );

         MFnCompoundAttribute fnRows;
         rows = fnRows.create( "rows", "rws",
                   &status );
         MCHECKERROR( status, "Cannot create rows attribute" );
         status = fnRows.addChild( MODBCQuery::columns );
         MCHECKERROR( status, "Cannot add columns as a child" );
         status = fnRows.setArray( true );
         MCHECKERROR( status, "Cannot set rows to array" );
         status = fnRows.setUsesArrayDataBuilder( true );
         MCHECKERROR( status, "Cannot set rows to use bilder" );


Nothing terribly exciting here.  I've gone through all the
reccomendations (conflicting many times with eachother) to get this
properly ordered.  One version even had the fnRows.create( "rows"....
function above the creation of the columns attribute, but it still did
the same thing.  What is it doing you ask?

// ::compute snip

         // get the output array and it's associated builder
         MArrayDataHandle dhRowsArray = block.outputValue( rows, &status );
         MCHECKERROR( status, "cannot get dhRowsArray" );
         MArrayDataBuilder bdRows = dhRowsArray.builder( &status );
         MCHECKERROR( status, "Cannot get rows builder" );
         while(<whenever>) {
           MArrayDataHandle adhColumns = bdRows.addLastArray( &status );
           MCHECKERROR( status, "Cannot get array data handle for
       columns" );
           MArrayDataBuilder bdColumns = adhColumns.builder( &status );
           MCHECKERROR( status, "cannot get array data builder for
       columns" );
         
           for( i = 0; i < nColumns; i++ ) {
             MDataHandle dhColumn = bdColumns.addLast( &status );
             MCHECKERROR( status, "cannot add last element to column" );
             MString sData = (char*) column_variables[i];
             dhColumn.set( sData );
           }

           status = adhColumns.set( bdColumns );
           MCHECKERROR( status, "Cannot set adhColumns to bdColumns" );

                             ...
                         }
So when stepping through line by line in the nearly infinite variations
of this code, it always dies where I try and get the builder for the
columns, "MArrayDataBuilder bdColumns = adhColumns.builder( &status
);".  All of my error checking passes up to this point, and using
wonderful (sarcasm intended) VC++ debugger the plugin's compute node
simply exits without any kind of error or complaint.  It doesn't make it
to the MCHECKERROR on the line after, it just exits (really, when
debugging, I would prefer a crash, I like to be able to tell what's
happened).

So what's happening?  Are nested arrayDataBuilders on an output a
no-no?  Seems a bit odd.  Is there any other way to do this without
having to write another MPxData container?  It just limits the
flexability of this node severly.

Thanks for any help in advance, I'm really stumped by this one.

Rich

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
List-help: <mailto:listar@(protected)?Subject=help>
List-archive: <http://www.highend3d.com/maya/devarchive/>