<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Moving collections up and down layer hierarchy using python in Render Setup in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8324971#M9024</link>
    <description>&lt;P&gt;Hi Li, thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My point about preserving the children is that, it's not just children that are removed, it's anything that is lower down in the layer list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say I had 3 layers, beauty, fur, shadows and we're currently viewing the&amp;nbsp;beauty&amp;nbsp;layer, I hit 'Save' and an empty '_untitled_' collection is created above&amp;nbsp;an existing collection 'bty_Environment' in this layer (see image 1), when I run cmds.delete('_untitled_') as a post save cleanup, 'bty_Environment' is deleted too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue.PNG" style="width: 321px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555893iA873F754D5AA15BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue.PNG" alt="MayaRenderSetupIssue.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I was to move '_untitled_' to the bottom of the layer heirarchy (see image 2) and run cmds.delete('_untitled_') - then only that empty collection is removed, so in order to do this as an auto post save cleanup, I need to work out a way of moving the _untitled_ collection down, using python without human interaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue2.PNG" style="width: 306px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555894iCEEE5C0240FD5C88/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue2.PNG" alt="MayaRenderSetupIssue2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am aware that this has been addressed in 2018 but we cannot currently move to that version until&amp;nbsp;the pipeline has been fully moved across to support it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 13:42:49 GMT</pubDate>
    <dc:creator>licenses</dc:creator>
    <dc:date>2018-10-10T13:42:49Z</dc:date>
    <item>
      <title>Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8316368#M9022</link>
      <description>&lt;P&gt;Pretty much as it says in the title, does anyone know how to move&amp;nbsp;collections up and down layer hierarchy using python in Render Setup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reason I ask is so that I can blow away the spurious '_untitled' collection that gets generated when you save a scene and do not have the 'master scene' selected to view.&amp;nbsp; If the '_untitled' collection is not at the bottom of the hierarchy when you delete it, everything below gets removed too!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Craig&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 19:00:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8316368#M9022</guid>
      <dc:creator>licenses</dc:creator>
      <dc:date>2018-10-05T19:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8323801#M9023</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to reproduce this issue, but I am not sure about "&lt;STRONG&gt;&lt;EM&gt;If the '_untitled' collection is not at the bottom of the hierarchy when you delete it, everything below gets removed too!&lt;/EM&gt;&lt;/STRONG&gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The _untitled_ collection is created when master layer isn't selected and creating objects in the scene. I tried to remove the _untitled_ later. It removes the children below it as expected. Are you trying to preseve the children? Could you give me more details?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW: In Maya 2018 Update 3, there is a &lt;A href="http://help.autodesk.com/view/MAYAUL/2018/ENU/?guid=GUID-A622E999-38E6-46B1-939F-F8FA6D3D61BA" target="_blank"&gt;new option to disable creating _untitled_ automatically.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 02:34:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8323801#M9023</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2018-10-10T02:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8324971#M9024</link>
      <description>&lt;P&gt;Hi Li, thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My point about preserving the children is that, it's not just children that are removed, it's anything that is lower down in the layer list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say I had 3 layers, beauty, fur, shadows and we're currently viewing the&amp;nbsp;beauty&amp;nbsp;layer, I hit 'Save' and an empty '_untitled_' collection is created above&amp;nbsp;an existing collection 'bty_Environment' in this layer (see image 1), when I run cmds.delete('_untitled_') as a post save cleanup, 'bty_Environment' is deleted too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue.PNG" style="width: 321px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555893iA873F754D5AA15BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue.PNG" alt="MayaRenderSetupIssue.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I was to move '_untitled_' to the bottom of the layer heirarchy (see image 2) and run cmds.delete('_untitled_') - then only that empty collection is removed, so in order to do this as an auto post save cleanup, I need to work out a way of moving the _untitled_ collection down, using python without human interaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue2.PNG" style="width: 306px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555894iCEEE5C0240FD5C88/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue2.PNG" alt="MayaRenderSetupIssue2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am aware that this has been addressed in 2018 but we cannot currently move to that version until&amp;nbsp;the pipeline has been fully moved across to support it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 13:42:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8324971#M9024</guid>
      <dc:creator>licenses</dc:creator>
      <dc:date>2018-10-10T13:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8324979#M9025</link>
      <description>&lt;P&gt;Hi Li, thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My point about preserving the children is that, it's not just children that are removed, it's anything that is lower down in the layer list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say I had 3 layers, beauty, fur, shadows and we're currently viewing the&amp;nbsp;beauty&amp;nbsp;layer, I hit 'Save' and an empty '_untitled_' collection is created above&amp;nbsp;an existing collection 'bty_Environment' in this layer (see image 1), when I run cmds.delete('_untitled_') as a post save cleanup, 'bty_Environment' is deleted too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue.PNG" style="width: 321px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555893iA873F754D5AA15BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue.PNG" alt="MayaRenderSetupIssue.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I was to move '_untitled_' to the bottom of the layer heirarchy (see image 2) and run cmds.delete('_untitled_') - then only that empty collection is removed, so in order to do this as an auto post save cleanup, I need to work out a way of moving the _untitled_ collection down, using python without human interaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayaRenderSetupIssue2.PNG" style="width: 306px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555894iCEEE5C0240FD5C88/image-size/large?v=v2&amp;amp;px=999" role="button" title="MayaRenderSetupIssue2.PNG" alt="MayaRenderSetupIssue2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am aware that this has been addressed in 2018 but we cannot currently move to that version until&amp;nbsp;the pipeline has been fully moved across to support it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 13:45:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8324979#M9025</guid>
      <dc:creator>licenses</dc:creator>
      <dc:date>2018-10-10T13:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8326448#M9026</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I remembered renderSetup's data is related to each other, so you can't just use delete command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are some APIs provided for renderSetup in Python, you could use APIs to detach the collections and delete them like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import maya.app.renderSetup.model.collection as collection&lt;BR /&gt;import maya.app.renderSetup.model.renderLayer as renderLayer&lt;BR /&gt;import maya.app.renderSetup.model.renderSetup as renderSetup&lt;BR /&gt;import maya.cmds as cmds&lt;BR /&gt;&lt;BR /&gt;rs = renderSetup.instance() &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;layers = rs.getRenderLayers()&lt;BR /&gt;&lt;BR /&gt;for layer in layers:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; collections&amp;nbsp; = layer.getCollections()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for collection in collections:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = collection.name()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "_untitled_" in name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.detachCollection(collection)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmds.delete(name)
&lt;/PRE&gt;
&lt;P&gt;It should remove all collections named with "_untitled_*" directly under the renderLayers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't reproduce the way you've mentioned with Maya 2017 Update 5. So, I tested with _untitled_ collections created when active layer wasn't master layer. Using delete will remove the collection below like you mentioned. The script was working fine with that(remove all _untitled_ layers without deleting other collections below them)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 01:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8326448#M9026</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2018-10-11T01:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Moving collections up and down layer hierarchy using python in Render Setup</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8345868#M9027</link>
      <description>&lt;P&gt;Amazing, thanks Li!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was - detachCollection(collection) that I was looking for, works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Craig&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 13:42:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/moving-collections-up-and-down-layer-hierarchy-using-python-in/m-p/8345868#M9027</guid>
      <dc:creator>licenses</dc:creator>
      <dc:date>2018-10-19T13:42:27Z</dc:date>
    </item>
  </channel>
</rss>

