PDA

View Full Version : MEL command struggle - "polyChipOff"


H3ro
07-23-2006, 02:53 PM
I am having problmes with the "polyChipOff" command. I want to seperate all the faces stored in a variable from the origianl mesh, but as one face is removes, the name of the others change.


{
string $breakFaces[] =`ls -sl`;
int $noOfBreakFaces = size($breakFaces);
print $breakFaces;

string $polyChipping = "polyChipOff -ch 1 -kft 0 -dup 0 -pvx 10.03513401 -pvy -0.7370185994 -pvz -0.08563854789 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0 -gx 0 -gy -1 -gz 0 -att 0 -mx 0 -my 0 -mz 0 ";


for( $x=0; $x<=$noOfBreakFaces; $x++)
{
eval($polyChipping + $breakFaces[$x]);
polyPerformAction polySeparate o 0;
}
}



thanks in advance

Segmoria
07-23-2006, 05:46 PM
This seems like it should do the job:
{
string $breakFaces[] =`ls -sl -fl`;
string $polyChipping = "polyChipOff -ch 1 -kft 0 -dup 0 -pvx 10.03513401 -pvy -0.7370185994 -pvz -0.08563854789 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0 -gx 0 -gy -1 -gz 0 -att 0 -mx 0 -my 0 -mz 0";

for($face in $breakFaces)
{
$polyChipping += " " + $face;
}
eval($polyChipping);
polyPerformAction polySeparate o 0;
}

Though copying what the script editor spits out when a tool is used may not always be the right way to construct a script (in this case I'm refering to the use of the "polyPerformAction polySeparate o 0").

Anyway I also noticed in your above script that you use:
for( $x=0; $x<=$noOfBreakFaces; $x++)

which should be corrected to the following, to avoid trying to access invalid array elements:
for( $x=0; $x<$noOfBreakFaces; $x++)
or use the for/in loop for more convenience

Hope this helps!

H3ro
07-23-2006, 08:24 PM
Thanks. Works perfect.

One more question:
How can I combine all of the seperated faces and store the new object in an array?

Segmoria
07-24-2006, 12:52 AM
So you want to write a script that detaches the selected faces into another object? If so, there is already a script that does this exact task, it's called "Detach Seperate" and is very usefull indeed.
You can download it from here:
http://www.highend3d.com/maya/downloads/mel_scripts/polygon/1149.html

This script uses a different work-around to detaching the faces, not by using polySeparate or polyChipOff but by duplicating the object, deleting the selected faces from the first object and then deleting the inverted selection of the faces, that the user had made, from the second object. A very handy little script, I use it almost everyday.

CGTalk Moderation
07-24-2006, 12:52 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.