Softimage Forum (Read Only)
Welcome to Autodesk’s Softimage Forums. Share your knowledge, ask questions, and explore popular Softimage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Instance To Duplicate (JScript)

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
612 Views, 0 Replies

Instance To Duplicate (JScript)

Hi ppl,

I want to share my "instance to duplicate" JScript that we are using in our company. Hope it will help someone.

Usage Example :
1) Select "test_Instance" named object (or "test_Instance1", "test_Instance2" it will work with multiple objects)
2) Run the script.
3) It will duplicates the "test" named object and will do "Match all Transform" to the selected instances. After that it will delete instances.

Salute.



/**
* Lighthouse VFX <lhvfx.com> Instance To Dublicate v1.0
*
* @Author Bulent Gercek <bulentgercek@gmail.com>
*/
function instanceChanger()
{
LogMessage("Lighthouse VFX / Instance To Dublicate v1.0 | Author : Bulent Gercek <bulentgercek@gmail.com>");

var countStart;
var objMemory = selectionToMemory();

if (objMemory.length < 1)
LogMessage("Warning : Please select one ore more object from scene and try again.");

for (count=0; count<objMemory.length; count++) {

objNameInfo = nameSplitter(objMemory);

if (objNameInfo) {
SelectObj("B:" + objNameInfo, null, true);
Duplicate(Application.selection(0), null, 2, 1, 1, 0, 0, 1, 0, 1, null, null, null, null, null, null, null, null, null, null, 0);
MatchTransform(Application.selection(0), objNameInfo + "_Instance" + objNameInfo, siSRT, null);
DeleteObj(objNameInfo + "_Instance" + objNameInfo);
SetValue(Application.selection(0) + ".Name", objNameInfo + "_Instance" + objNameInfo, null);
}
}
LogMessage("...");
}

function selectionToMemory()
{
var objSel = Application.selection;
var objNameArray = new Array();

for (i=0; i<objSel.count; i++) {
objNameArray = objSel(i).Name;
}
return objNameArray;
}

function nameSplitter(objName)
{
infoArray = new Array();
objNameSplitterArray = objName.split("_Instance");

if (objNameSplitterArray.length > 1) {
infoArray = objNameSplitterArray;
infoArray = objNameSplitterArray;

if (objNameSplitterArray != "") infoArray = false; else infoArray = true;
return infoArray;
} else {
LogMessage("Warning : Object '" + objName + "' is not a instance object.");
return false;
}
}

/* Run */
instanceChanger();
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report