PDA

View Full Version : Move vertex information from one object to another


H3ro
06-21-2006, 02:40 PM
I am trying to modefy a mesh that I have, but I cant change the X and Z position of the vertexes, so I can only change them I y.

To do so I am trying to make a "cleanup" script, that first make a copy of the mesh (befor i modefy it) and then when I want to it sets the X and Z position of all the vertexes right.

My script dont work, any inputs would have been great.


//set object and make a reference
global proc setObj ()
{
string $objMain[] = `ls -sl`;
duplicate;

string $objRef[] = `ls -sl`;
move -r 0 8 0;
rename $objMain[0] "targetObjectForCube";
rename $objRef[0] "BaseObjectForCube";
setAttr "BaseObjectForCube.visibility" 0;
}

//global proc copy ()
{
//save vertex information
select "BaseObjectForCube";
ConvertSelectionToVertices;
string $vertRef[] = `ls -sl -flatten`;


select "targetObjectForCube";
ConvertSelectionToVertices;
string $vertTarget[] = `ls -sl -flatten`;

float $noOfvert = size($vertTarget);

//find the position of the vertex
for( $i = 0; $i < $noOfvert; $i++ )
{
vector $position = `xform -ws -q -t $vertRef[$i]`;

//apply it to the other object
setAttr "targetObjectForCube.pnts["+$i+"].pntx" $position.x;
setAttr "targetObjectForCube.pnts["+$i+"].pntz" $position.z;
}
}


Thanks:)

H3ro
06-21-2006, 11:01 PM
FIxed it :


//set object and make a reference
global proc setObj()
{
string $objMain[] = `ls -sl`;
duplicate;

string $objCopy[] = `ls -sl`;
move -r 0 8 0;
rename $objMain[0] "MainObjectForCube";
rename $objCopy[0] "CopyObjectForCube";
setAttr "CopyObjectForCube.visibility" 0;
}

//copy Information
global proc copy()
{
//save vertex information
select "CopyObjectForCube";
ConvertSelectionToVertices;
string $vertCopy[] = `ls -sl -flatten`;


select "MainObjectForCube";
ConvertSelectionToVertices;
string $vertMain[] = `ls -sl -flatten`;

float $noOfvert = size($vertMain);

//find the position of the vertex
for( $i = 0; $i < $noOfvert; $i++ )
{
vector $positionCopy = `xform -ws -q -t $vertCopy[$i]`;
vector $positionMain = `xform -ws -q -t $vertMain[$i]`;

float $copyX = $positionCopy.x;
float $copyY = $positionCopy.y;
float $copyZ = $positionCopy.z;

float $mainX = $positionMain.x;
float $mainY = $positionMain.y;
float $mainZ = $positionMain.z;

//apply it to the other object
select -r $vertMain[$i];
move $copyX $mainY $copyZ;
}
}

CGTalk Moderation
06-21-2006, 11:01 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.