https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&feed=atom&action=history
IC Python API:Loading All Props - Revision history
2024-03-29T01:20:11Z
Revision history for this page on the wiki
MediaWiki 1.26.2
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3386&oldid=prev
Chuck (RL): /* Loading All Template Props */
2019-05-21T08:05:52Z
<p><span dir="auto"><span class="autocomment">Loading All Template Props</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 08:05, 21 May 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l68" >Line 68:</td>
<td colspan="2" class="diff-lineno">Line 68:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>         index += 1</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>         index += 1</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></syntaxhighlight></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></syntaxhighlight></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[File:Iclone_python_api_loading_all_props_01.png]]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Everything Put Together ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Everything Put Together ==</div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3384&oldid=prev
Chuck (RL): /* Loading All Template Props */
2019-05-21T08:02:14Z
<p><span dir="auto"><span class="autocomment">Loading All Template Props</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 08:02, 21 May 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l38" >Line 38:</td>
<td colspan="2" class="diff-lineno">Line 38:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Loading All Template Props ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Loading All Template Props ==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>With the template folder path, we can search the directory for all '''iProps'''.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>With the template folder path, we can search the directory for all '''iProps'''<ins class="diffchange diffchange-inline">, load them into iClone, assemble them in a single line, and scale them down to stand side-by-side</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><syntaxhighlight lang="Python"></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><syntaxhighlight lang="Python"></div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3383&oldid=prev
Chuck (RL): /* Template Folder Path */
2019-05-21T08:00:56Z
<p><span dir="auto"><span class="autocomment">Template Folder Path</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 08:00, 21 May 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l34" >Line 34:</td>
<td colspan="2" class="diff-lineno">Line 34:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># Drill down to the beveled shapes directory</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># Drill down to the beveled shapes directory</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>path = ic_template_path + r"\iClone Template\Props\3D Blocks\Beveled"</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>path = ic_template_path + r"\iClone Template\Props\3D Blocks\Beveled"</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div></<del class="diffchange diffchange-inline">syntaxhighligh</del>></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></<ins class="diffchange diffchange-inline">syntaxhighlight</ins>></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Loading All Template Props ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Loading All Template Props ==</div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3382&oldid=prev
Chuck (RL) at 08:00, 21 May 2019
2019-05-21T08:00:22Z
<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 08:00, 21 May 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{TOC}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{TOC}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">This article will go over the use of Python '''os''' and '''winreq''' to load all props within the iClone Template directory. Learn how to deal with and access the Window's file system with Python.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Necessary Modules ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Necessary Modules ==</div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3381&oldid=prev
Chuck (RL): /* APIs Used */
2019-05-21T07:57:19Z
<p><span dir="auto"><span class="autocomment">APIs Used</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 07:57, 21 May 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l119" >Line 119:</td>
<td colspan="2" class="diff-lineno">Line 119:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RFileIO#LoadFile | RLPy.RFileIO.LoadFile() ]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RFileIO#LoadFile | RLPy.RFileIO.LoadFile() ]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RScene#FindObject | RLPy.RScene.FindObject() ]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RScene#FindObject | RLPy.RScene.FindObject() ]]</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">* [[ IC_Python_API:RLPy_EObjectType_Prop, os#path.splitext | RLPy.EObjectType_Prop, os.path.splitext() ]]</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RTime | RLPy.RTime() ]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RTime | RLPy.RTime() ]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RVariant | RLPy.RVariant() ]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* [[ IC_Python_API:RLPy_RVariant | RLPy.RVariant() ]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></div></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></div></div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Loading_All_Props&diff=3380&oldid=prev
Chuck (RL): Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}} == Necessary Modules == Besides the RLPy standard module, we'll need two system based modules to load a..."
2019-05-21T07:56:29Z
<p>Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}} == Necessary Modules == Besides the RLPy standard module, we'll need two system based modules to load a..."</p>
<p><b>New page</b></p><div>{{TOC}}<br />
{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}<br />
<br />
== Necessary Modules ==<br />
<br />
Besides the RLPy standard module, we'll need two system based modules to load a prop from a directory with the likes of '''os''' and '''winreg'''.<br />
<br />
<syntaxhighlight lang="Python"><br />
import RLPy<br />
import os<br />
import winreg<br />
</syntaxhighlight><br />
=== os ===<br />
<br />
The '''os''' module provides a portable way of using operating system dependent functionality. For more information, see [https://docs.python.org/3/library/os.html os.html]<br />
<br />
=== winreg ===<br />
<br />
'''winreg''' offers functions that exposes the Windows registry API to Python. For more information, see [https://docs.python.org/3/library/winreg.html winreg.html]<br />
<br />
== Template Folder Path ==<br />
<br />
Let's get the directory path for the iClone '''Template''' folder.<br />
<br />
<syntaxhighlight lang="Python"><br />
# Get the iClone 7 default template path<br />
registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)<br />
rawKey = winreg.OpenKey(registry, r"SOFTWARE\Reallusion\iClone\7.0")<br />
ic_template_path = os.path.abspath(<br />
winreg.QueryValueEx(rawKey, "Template Data")[0])<br />
<br />
# Drill down to the beveled shapes directory<br />
path = ic_template_path + r"\iClone Template\Props\3D Blocks\Beveled"<br />
</syntaxhighligh><br />
<br />
== Loading All Template Props ==<br />
<br />
With the template folder path, we can search the directory for all '''iProps'''.<br />
<br />
<syntaxhighlight lang="Python"><br />
index = 0<br />
<br />
for file_name in os.listdir(path):<br />
if file_name.endswith(".iProp"): # If the file is an iProp<br />
<br />
# Load the prop into the scene<br />
RLPy.RFileIO.LoadFile(path+"\\"+file_name)<br />
<br />
# Grab the loaded prop by name<br />
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, os.path.splitext(file_name)[0])<br />
<br />
# Retrieve the transform datablock to move the prop where we desire<br />
prop_control = prop.GetControl("Transform")<br />
data_block = prop_control.GetDataBlock()<br />
<br />
# Align the props side by side<br />
data_block.SetData("Position/PositionX", RLPy.RTime(0),<br />
RLPy.RVariant(index * 50 - 280))<br />
<br />
# Scale the props down<br />
data_block.SetData("Scale/ScaleX", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
data_block.SetData("Scale/ScaleY", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
data_block.SetData("Scale/ScaleZ", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
<br />
# Increment the index for placing the next prop<br />
index += 1<br />
</syntaxhighlight><br />
<br />
== Everything Put Together ==<br />
<br />
You can copy and paste the following code into a PY file and load it into iClone via '''Script > Load Python'''.<br />
<br />
<syntaxhighlight lang="Python"><br />
import RLPy<br />
import os<br />
import winreg<br />
<br />
# Get the iClone 7 default template path<br />
registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)<br />
rawKey = winreg.OpenKey(registry, r"SOFTWARE\Reallusion\iClone\7.0")<br />
ic_template_path = os.path.abspath(<br />
winreg.QueryValueEx(rawKey, "Template Data")[0])<br />
<br />
# Drill down to the beveled shapes directory<br />
path = ic_template_path + r"\iClone Template\Props\3D Blocks\Beveled"<br />
<br />
index = 0<br />
<br />
for file_name in os.listdir(path):<br />
if file_name.endswith(".iProp"): # If the file is an iProp<br />
<br />
# Load the prop into the scene<br />
RLPy.RFileIO.LoadFile(path+"\\"+file_name)<br />
<br />
# Grab the loaded prop by name<br />
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, os.path.splitext(file_name)[0])<br />
<br />
# Retrieve the transform datablock to move the prop where we desire<br />
prop_control = prop.GetControl("Transform")<br />
data_block = prop_control.GetDataBlock()<br />
<br />
# Align the props side by side<br />
data_block.SetData("Position/PositionX", RLPy.RTime(0),<br />
RLPy.RVariant(index * 50 - 280))<br />
<br />
# Scale the props down<br />
data_block.SetData("Scale/ScaleX", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
data_block.SetData("Scale/ScaleY", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
data_block.SetData("Scale/ScaleZ", RLPy.RTime(0), RLPy.RVariant(0.4))<br />
<br />
# Increment the index for placing the next prop<br />
index += 1<br />
</syntaxhighlight><br />
<br />
=== APIs Used ===<br />
You can research the following references for the APIs deployed in this code.<br />
<br />
<div style="column-count:4; -moz-column-count:4; -webkit-column-count:4"><br />
* [[ IC_Python_API:RLPy_RFileIO#LoadFile | RLPy.RFileIO.LoadFile() ]]<br />
* [[ IC_Python_API:RLPy_RScene#FindObject | RLPy.RScene.FindObject() ]]<br />
* [[ IC_Python_API:RLPy_EObjectType_Prop, os#path.splitext | RLPy.EObjectType_Prop, os.path.splitext() ]]<br />
* [[ IC_Python_API:RLPy_RTime | RLPy.RTime() ]]<br />
* [[ IC_Python_API:RLPy_RVariant | RLPy.RVariant() ]]<br />
</div></div>
Chuck (RL)