Main
|
Resume
|
Showreel
|
Blog
|
Script
|
Contact
connexion
go to footer
expand all
|
collapse all
languages
class
All
JScript|XSI
Python|XSI
JScript|WEB
Python|Maya
All
Memo
learning
DDD
php
tool
keyboard tooltips
rig
Obj_Duplicator_and_Cns_Direction()
- All - felixlecha
// Duplicate and Parent first picked object on Current selected object and Constrain in Direction to picked Target // Obj_Duplicator_and_Cns_Direction(); function Obj_Duplicator_and_Cns_Direction() { // Select Root For Anchors var aSel = new Array(); aSel = getValue("SelectionList"); // Pick the Object To Duplicate and Parent var rtn = PickObject( "Select Mesh", "Select Mesh" ); var oObj = rtn(2); // Pick the Target for the Constraint var rtn = PickObject( "Select Camera", "Select Camera" ); var oTarget = rtn(2); // Create new Group var oSceneRoot = Application.ActiveProject.ActiveScene.Root; var oGroup = oSceneRoot.AddGroup(); oGroup.Name = oObj.name + "_Group"; // Hide Command Log SetValue("preferences.scripting.cmdlog", false, null); var oProgressBar = XSIUIToolkit.progressbar; oProgressBar.maximum = aSel.count; oProgressBar.visible = true; oProgressBar.caption = "[ Duplicate, Parent and Cns Direction ]"; for( i = 0; i < aSel.count && !oProgressBar.cancelpressed; i++ ) { var oNewObj = SIDuplicate( oObj ); ParentObj(aSel(i), oNewObj); oNewObj = dictionary.getObject( oNewObj, false); oNewObj.kinematics.global.transform = oNewObj.parent.kinematics.global.transform; // Add new null to Group oGroup.AddMember( oNewObj, false ); // Add Cns Direction on Target oNewObj.kinematics.AddConstraint( "Direction", oTarget, 0); oNewObj.kinematics.dircns.dirx.value = 0; oNewObj.kinematics. dircns.diry.value = 1; oNewObj.kinematics.dircns.dirz.value = 0; oProgressBar.statustext = "[ " + oNewObj + " ] " + oProgressBar.increment() + " / " + oProgressBar.maximum; oProgressBar.increment(); } oProgressBar.visible = false; }