PDA

View Full Version : delete half of model (polygon)?


CoolDuck
09-29-2005, 11:13 PM
Would it be possible to write a script that deletes half of a model, the faces (everything on the -X side)?

It would be a big time saver for me. I use smooth proxy a lot with the mirror function. Sometimes when I want to do extrudes in the vertical middle of the model I have to UNsmooth proxy first / do my stuff / then smooth proxy again. But then I have to carefully select the left side of the model and delete. Which cost time if you need to do it 20 times a day.
It's not a big thing, but I think some modelers will find this useful. If some programmers can elaborate on this, that would be great! Thanks in advance.

el diablo
09-30-2005, 04:37 AM
global proc killHalf() {

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

select -r ($sel[0] + ".vtx
");

string $pnts[] = `ls -sl -fl`;

select -cl;

for($pnt in $pnts) {

float $pos[] = `xform -q -ws -t $pnt`;

if($pos[0] < 0) {

select -add $pnt;

}

}

ConvertSelectionToFaces;

delete;

}

killHalf;

CoolDuck
09-30-2005, 08:46 AM
HI thanks for your script, very cool!
But it's not always accurate, on a simple model it worked, but on a more detailed model it selection too much.

Check the screenshot:
http://www.4legsmedia.com/temp/bakuSelectionError.jpg

But I'm gonna do some work myself too, checking out what xform can do for me in the manual.

ulei
09-30-2005, 09:09 AM
just a fast guess: move the model a little bit so there are no vertices that could belong to both sides ...

CoolDuck
09-30-2005, 01:16 PM
Hey that's not a bad idea, when I first read it, I thought: "no way". But I moved the object .001 to the X+ and it worked.
I'm gonna to program the move of .001 in the script, and make it move back to 0 when done.

I hope this is a fail proof method.
Thanks!

CoolDuck
09-30-2005, 02:05 PM
I have changed the code to this:


global proc polyKillHalf() {
// put selection in array
string $objSelected[] = `ls -sl`;

// move object to the right
setAttr ($objSelected[0]+".translateX") 0.001;

// select vertices of model
select -r ($objSelected[0] + ".vtx
");

// deselect right side of vertices
string $pnts[] = `ls -sl -fl`;
select -cl;

for($pnt in $pnts) {
float $pos[] = `xform -q -ws -t $pnt`;
if($pos[0] < 0) {
select -add $pnt;
}
}

// delete half
ConvertSelectionToFaces;
delete;

// move object to center again
setAttr ($objSelected[0]+".translateX") 0;
}
polyKillHalf;


Thanks for the help!

westiemad
09-30-2005, 02:05 PM
instead of programming a movement of the model, just change the if($pos[0] < ) statement

CGTalk Moderation
09-30-2005, 02:05 PM
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.