Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 09-08-2016 , 01:34 PM
Registered User
Join Date: Aug 2016
Posts: 2

need help >.< copying and pasting values!

Hello everyone

Im currently scripting a tool which will allow me to copy the transforms on all a models vertices and paste them onto a duplicate of the model.

The purpose of this is so I can sculpt on a rigs model to fix bad deformations ( aka: the elbow when the arm bends ) and then copy and Paste the changes onto a corrective blendshape after which i clear out the transforms on all the vertexes.

The problem i am having however is when i try to "getAttr" the vertexes transforms. I get one of two errors,

// Error: line 32: Cannot convert data of type float[] to type float. //
// Error: line 1: Cannot convert data of type float[] to type float.
Start of trace: (command window: line 32).


or

Error reading data element number 1


Im having trouble understanding what the issue is because to me this should be working :S

Code:
string $sel[] = `ls -sl`;

duplicate $sel[0];

string $dup = `rename ("bShp"+$sel[0]+"corrective")`;

move -15 0 0;

int $count[] = `polyEvaluate -v $sel[0]`;
 
int $verNumber = $count[0];

int $vertNum = 0;

select -cl;

float $dupCorrectiveVal;


for ($i=0; $i<$verNumber; ++$i){
    
    string $verts = ($sel[0]+".vtx["+ $vertNum +"]");
    
    
    string $dup_verts = ($dup +".vtx["+ $vertNum +"]");
    
    
    string $VertAttrs[] = {"pntx","pnty","pntz"};
    
     for ($attr in $VertAttrs){
            
           $dupCorrectiveVal = `getAttr ($verts + "." + $attr)`;
            
            setAttr ($dup_verts + "." + $attr) $dupCorrectiveVal;
            
            setAttr ($verts + "." + $attr) 0;
            
            
        }
    
    $vertNum = (1 + $vertNum); 
}

does anyone have any advice?


Last edited by NextDesign; 10-08-2016 at 01:00 AM.
# 2 10-08-2016 , 12:59 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
It's telling you that getAttr returns an array of four floating point values in this case. So change

float $dupCorrectiveVal;

to

float $dupCorrectiveVal[4];


Imagination is more important than knowledge.
# 3 10-08-2016 , 02:24 AM
Registered User
Join Date: Aug 2016
Posts: 2
Firstly thank you for responding!

Why is it turning it into an array? usually it comes out as a single float number which i wanted to input into the corresponding vertex on the duplicate model.

if it turns into an array how can I paste it into another vertex transforms?

# 4 10-08-2016 , 07:59 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Print out the values and make sure it's returning what you expect. One thing I notice is that you're using vertNum as a counter. Don't do that - you already have an increment counter, i.

Code:
string $verts = ($sel[0]+".vtx["+ $vertNum +"]");
Should be:
Code:
string $verts = ($sel[0]+".vtx["+ $i +"]");
You also have two variables named almost the same thing, verNumber and vertNum. You should choose more unique names so that you don't confuse yourself.


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads