  | | | Basic scripting question.. | Basic scripting question.. 2005-04-14 - By Bradley R. Gabe
Back For anyone concerned about performance, using a transform object is significantly faster that going the match transformation route. Also, check out the AddNull() method. It creates a new null as the child of the object that calls it:
// Create a normalized transform var trans = XSIMath.CreateTransform;
// Loop through the selection for(var e = new Enumerator(selection); !e.atEnd(); e.moveNext()){
// For each obj, add a null var obj = e.item(); var node = obj.AddNull(obj.name + '_NUL');
// Transform the null to rest pose node.kinematics.local.transform = trans; }
> From the online help: >(select a word in your script and click the ? button in the script editor, >it ll give your the appropriate info) > >Scripting Syntax >GetPrim (PresetObj, [Name], [Parent], [Primitive]) > > >so the GetPrim "Null" line would become something like: >GetPrim "Null" , nill & "_null" > >now there is also the MatchTransform command, >that will allow to match the transforms of the null to the object, >to avoid doing a constraint and then removing it >and then the ParentObj command to do the parenting. >Something like: > >-- ------ >set A=GetValue("SelectionList") > for each ab in A > GetPrim "Null", ab & "_null" > MatchTransform , ab, siSRT > ParentObj ab & "_null", ab > next >-- ---- -- > >that should do the trick. >You didnt want any constraints in the end right? > >Peter > > > > > > > > > > > >-- -- Original Message -- -- >From: <mailto:lee.hallett@(protected)>Lee Hallett >To: <mailto:XSI@(protected)>XSI@(protected) >Sent: Thursday, April 14, 2005 2:11 PM >Subject: Basic scripting question.. > >I'm trying to modify matts nullifier script, but my scripting is somewhat >below par (non existent). > >The two extra things I need to do are >1) Make the null the parent of the object >2) Rename the null to *Objectname*_Null > >Anyone got any quick tips!! > >Original script: > >' nullifier v1.1 by Matt Lowery > >Dim A >Dim nul >Dim B > >set A=GetValue("SelectionList") >for each ab in A > GetPrim "Null" > set nul=GetValue("SelectionList") > for each nil in nul > ApplyCns "Pose",nil,ab > Duplicate nil > DeleteObj nil > next > set B=GetValue("SelectionList") > for each ba in B > RemoveAllCns ba > ApplyCns "Pose", ab, ba > next >next > >Lee|3d animation and design.. >Pixel pusher & 'telly colouring in' bloke > >There are only 10 sorts of people in the World - those that understand >binary, and those that don't. > * BBC Wales | C4 graphics area | Broadcasting House| Llandaff, > Cardiff. CF5 2QY. > ( +44 (0)29 203 23370 >e-* lee.hallett@(protected) > > > >http://www.bbc.co.uk/ > >This e-mail (and any attachments) is confidential and may contain >personal views which are not the views of the BBC unless specifically >stated. >If you have received it in error, please delete it from your system. >Do not use, copy or disclose the information in any way nor act in >reliance on it and notify the sender immediately. Please note that the >BBC monitors e-mails sent or received. >Further communication will signify your consent to this.
<html> <body> For anyone concerned about performance, using a transform object is significantly faster that going the match transformation route. Also, check out the AddNull() method. It creates a new null as the child of the object that calls it:<br><br> <font face="Courier New, Courier" color="#008000">// Create a normalized transform<br> </font><font face="Courier New, Courier">var trans = XSIMath.CreateTransform;<br><br> </font><font face="Courier New, Courier" color="#008000">// Loop through the selection<br> </font><font face="Courier New, Courier">for(var e = new Enumerator(selection); !e.atEnd(); e.moveNext()){<br><br> </font><font face="Courier New, Courier" color="#008000">// For each obj, add a null<br> </font><font face="Courier New, Courier"> var obj = e.item();<br> var node = obj.AddNull(obj.name + '_NUL');<br><br> </font><font face="Courier New, Courier" color="#008000">// Transform the null to rest pose<br> </font><font face="Courier New, Courier"> node.kinematics.local.transform = trans;<br> }<br><br> <br><br> </font><blockquote type=cite class=cite cite=""><font face="arial" size=2>From the online help: <br> (select a word in your script and click the ? button in the script editor, it ll give your the appropriate info)<br> </font><font face="arial"> <br> </font><font face="arial" size=2>Scripting Syntax <br> GetPrim (PresetObj, [Name], [Parent], [Primitive])<a name="wp659811"></a> <br> </font><font face="arial"> <br> <br> </font><font face="arial" size=2>so the </font><font face="courier" size=2>GetPrim "Null"</font><font face="arial" size=2> line would become something like:<br> GetPrim "Null" , nill & "_null"<br> </font><font face="arial"> <br> </font><font face="arial" size=2>now there is also the MatchTransform command, <br> that will allow to match the transforms of the null to the object, <br> to avoid doing a constraint and then removing it<br> and then the ParentObj command to do the parenting. <br> Something like: <br> </font><font face="arial"> <br> </font><font face="arial" size=2>-- ------<br> set A=GetValue("SelectionList") <br> for each ab in A <br> GetPrim "Null", ab & "_null" <br> MatchTransform , ab, siSRT<br> ParentObj ab & "_null", ab <br> next<br> -- ---- --<br> <br> that should do the trick. <br> You didnt want any constraints in the end right?<br> <br> Peter<br> <br><br> </font><h4><b> </b></h4><font size=2><br><br> </font><font face="arial" size=2><br> <b><br> </b></font><font face="arial"><br><br> </font> <dl> <dd>-- -- Original Message -- -- <br>
<dd>From:</b> <a href="mailto:lee.hallett@(protected)">Lee Hallett</a> <br>
<dd>To:</b> <a href="mailto:XSI@(protected)">XSI@(protected)</a> <br>
<dd>Sent:</b> Thursday, April 14, 2005 2:11 PM<br>
<dd>Subject:</b> Basic scripting question..<br><br>
<dd><font face="arial" size=2>I'm trying to modify matts nullifier script, but my scripting is somewhat below par (non existent). <br> </font><br>
<dd><font face="arial" size=2>The two extra things I need to do are</font> <br>
<dd><font face="arial" size=2>1) Make the null the parent of the object</font> <br>
<dd><font face="arial" size=2>2) Rename the null to *Objectname*_Null</font> <br><br>
<dd><font face="arial" size=2>Anyone got any quick tips!!</font> <br><br>
<dd><font face="arial" size=2>Original script:</font> <br><br>
<dd><font face="courier" size=2>' nullifier v1.1 by Matt Lowery</font> <br><br>
<dd><font face="courier" size=2>Dim A</font> <br>
<dd><font face="courier" size=2>Dim nul</font> <br>
<dd><font face="courier" size=2>Dim B</font> <br><br>
<dd><font face="courier" size=2>set A=GetValue("SelectionList")</font > <br>
<dd><font face="courier" size=2>for each ab in A</font> <br>
<dd> <font face="courier" size=2 >GetPrim "Null"</font> <br>
<dd> <font face="courier" size=2>set nul=GetValue("SelectionList")</font> <br>
<dd> <font face="courier" size=2>for each nil in nul</font> <br>
<dd> <font face="courier" size=2>ApplyCns "Pose",nil,ab< /font> <br>
<dd> <font face="courier" size=2>Duplicate nil</font> <br>
<dd> <font face="courier" size=2>DeleteObj nil</font> <br>
<dd> <font face="courier" size=2>next </font><br>
<dd> <font face="courier" size=2>set B=GetValue("SelectionList")</font> <br>
<dd> <font face="courier" size=2>for each ba in B</font> <br>
<dd> <font face= "courier" size=2>RemoveAllCns ba</font> <br>
<dd> <font face= "courier" size=2>ApplyCns "Pose", ab, ba </font><br>
<dd> <font face="courier" size=2>next</font> <br>
<dd><font face="courier" size=2>next</font> <br><br> <div align="center"> <dd><font face="arial" size=2>Lee|3d animation and design..</font></div> <div align="center"> <dd><font face="arial" size=2>Pixel pusher & 'telly colouring in' bloke< /font></div> <br> <div align="center"> <dd><font face="arial" size=1>There are only 10 sorts of people in the World - those that understand binary, and those that don't.<br> </font></div>
<dd><font face="Courier New, Courier"> </font><font face="wingdings" size =2>*</font><font face="tahoma"> </font><font face="tahoma" size=1> BBC Wales | C4 graphics area | Broadcasting House| Llandaff, Cardiff. CF5 2QY.</font> </b> <dd><font face="Courier New, Courier"> </font><font face="wingdings" size =2>(</b></font> <font face="tahoma" size=1> +44 (0 )29 203 23370</font> <dd><font face="arial" size=2>e-</font><font face="wingdings" size=2>*</font> <font face="Courier New, Courier"> </font> <font face="arial" size=1>lee.hallett@(protected)</font> <br> <br><br><br>
<dd><a href="http://www.bbc.co.uk/" eudora="autourl">http://www.bbc.co.uk/</a> <br><br>
<dd>This e-mail (and any attachments) is confidential and may contain<br>
<dd>personal views which are not the views of the BBC unless specifically<br>
<dd>stated.<br>
<dd>If you have received it in error, please delete it from your system. <br>
<dd>Do not use, copy or disclose the information in any way nor act in<br>
<dd>reliance on it and notify the sender immediately. Please note that the<br>
<dd>BBC monitors e-mails sent or received. <br>
<dd>Further communication will signify your consent to this. <br>
</dl></blockquote></body> </html>
|
|
 |