Select Similar tool to copy instance script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
My goal
to have a tool that find similar of my selection in the scene, make a copy instance of the selected and stay in the right position.
My workflow
Go to modify and open ''Replace object option'' mark the instance
I used this scrip to find similar object in the scene fx screws. Then i isolated the selected with ctrl + 1.
In ''view selected'', I again select all objects and then used ''shift select'' on one object, then press apply on the ''Replace Objects Options''. But it is not bullet proof some time the object fx screws is pointing in difference directions, And i have to do a lot of corrections after.
I dont know how any programming, but can any help me?
Thanks
Kent
mel
proc k_similarSelect ()
{
if (size(`filterExpand -sm 12`)) // If Object is selected (object mode)
{
string $saveSimilarC;
string $objToArray_sSC[];
string $selectedMain[] = `ls -sl -long -tr`;
// Get all meshes (with transforms) in the scene
string $sceneMeshes[] = `ls -long -type "mesh"`;
string $meshTransforms[] = `listRelatives -p -fullPath -type "transform" $sceneMeshes`;
for ($e=0; $e < size($selectedMain); $e++ )
{
int $selVertices[] = `polyEvaluate -vertex $selectedMain[$e]`;
float $selecArea[] = `polyEvaluate -worldArea $selectedMain[$e]`;
for ($r=0; $r < size($meshTransforms); $r++ )
{
int $toCompareVertices[] = `polyEvaluate -vertex $meshTransforms[$r]`;
float $toCompareArea[] = `polyEvaluate -worldArea $meshTransforms[$r]`;
if ($selVertices[0] == $toCompareVertices[0] && floatEq ($selecArea[0], $toCompareArea[0]))
{
$saveSimilarC += (" " + $meshTransforms[$r]);
}
}
}
$objToArray_sSC = stringToStringArray($saveSimilarC, " ");
select -r $objToArray_sSC;
$saveSimilarC = "";
}
// If Components are selected
if (size(`filterExpand -sm 31`) || size(`filterExpand -sm 32`) || size(`filterExpand -sm 34`))
{
SelectSimilar;
}
}
k_similarSelect();