PDA

View Full Version : query vertex color


fbitonti
12-31-2006, 03:57 AM
I am having a dificult time understanding the data types used when trying to query the color of a vertex. what kind of data is returned and how do you use it?

I am writing this littel script that querys a mesh loooking for a vertex in which the green attribute is equal to one.

The error I get is

// Error: Cannot use data of type float[] in a scalar operation. //

How do I convert the output into something that will work. I can't believe that I have never had to convert data types in mel before so i'm a bit lost. Thanks for any help you can give.

string $intSelection[] = `ls -sl -fl`;
polyColorPerVertex -g 1;
polySelectConstraint -m 3;
string $revSelection[] = `ls -sl -fl`;
// print $revSelection[0];
// print $revSelection[1];
// print $revSelection[2];
// print $revSelection[3];

select -cl;
//path to file
$filename = ("C:/2dTrussLoads.txt");

int $i;

// float $colorQuery;

// open the file for writing
$file = `fopen $filename "w"`;
global float $neigh1;
global float $neigh2;
// fprint
fprint $file ( "Nodal Loads" + "\n" );

while($i < size($revSelection)){
select -r $revSelection[$i];
//$colorQuery[0] = `polyColorPerVertex -q -g`;
if(`polyColorPerVertex -q -g` == 1){
fprint $file ( $neigh1 + "\n" );
fprint $file ( $neigh2 + "\n" );
}

if(`polyColorPerVertex -q -g` == 0){
fprint $file ( "0" + "\n" );
fprint $file ( "0" + "\n" );
}

$i = $i + 1;
}
// close file
fclose $file;
}

dbiggs
01-03-2007, 05:38 AM
You're almost there, the polyColorPerVertex command always returns a float array when you query a colour regardless of what flags you give it.

Here's the fix.

string $intSelection[] = `ls -sl -fl`;
polyColorPerVertex -g 1;
polySelectConstraint -m 3;
string $revSelection[] = `ls -sl -fl`;
// print $revSelection[0];
// print $revSelection[1];
// print $revSelection[2];
// print $revSelection[3];

select -cl;
//path to file
$filename = ("C:/2dTrussLoads.txt");

int $i;

// float $colorQuery;

// open the file for writing
$file = `fopen $filename "w"`;
global float $neigh1;
global float $neigh2;
// fprint
fprint $file ( "Nodal Loads" + "\n" );

while($i < size($revSelection)){
select -r $revSelection[$i];
//$colorQuery[0] = `polyColorPerVertex -q -g`;
float $color[] = `polyColorPerVertex -q -g`;
if($color[0] == 1){
fprint $file ( $neigh1 + "\n" );
fprint $file ( $neigh2 + "\n" );
}

float $color[] = `polyColorPerVertex -q -g`;
if($color[0] == 0){
fprint $file ( "0" + "\n" );
fprint $file ( "0" + "\n" );
}

$i = $i + 1;
}
// close file
fclose $file;

CGTalk Moderation
01-03-2007, 05:38 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.