<?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: Any way to toggle layer or model visibility through Python? in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493616#M6684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've not read every post in this thread, but if it helps:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Layer visibility will not affect occlusion functions&lt;/STRONG&gt;. So if you have models generated on a layer that is not visible, those models will still be included in occlusion tests. I'm 98.6 percent sure of this, unless it was changed in 2015.2, and I see nothing in the change log about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jan 2016 20:08:58 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2016-01-29T20:08:58Z</dc:date>
    <item>
      <title>Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493606#M6674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can fetch a layer list, and I can fetch the objects from a certain layer. However, I can't find anything that changes their visibility. Is that not implemented?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is, is it possible to run a script that I could use for toggling visibility based on a variable within the script? AFAIK the whole script is always run, so if I define switch variables and change them, they're reset every time I run the script again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2015 13:31:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493606#M6674</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2015-10-07T13:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493607#M6675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Visibility is managed in three places:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer Visibility (turn all features on / off)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Definition Query (exclude features)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Renderer (change symbol to none)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sounds like you are trying to filter out features based on a selection, you could add the list of selected objectIDS to the layer query definition thus "hiding" them. "...AND NOT OBJECTID IN (#,#,#,#)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See arcpy layer definition query here...&lt;A href="https://community.esri.com/thread/24700"&gt;use python to create definition query&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 19:49:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493607#M6675</guid>
      <dc:creator>BenNadler</dc:creator>
      <dc:date>2015-11-02T19:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493608#M6676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ZR, This is a CityEngine python question, and not an ArcPy question, right? Just clarifying for Ben.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know the answer, but I have a friend David with the same question. I sent him a link to this. Maybe one or the other of you will find the answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 16:17:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493608#M6676</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-11-06T16:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493609#M6677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have run into the same problem. I have been able to get the layer list into a web scene (see image below), but I am having the same problem. I am continuing to research it, but I bet it hinges on filtering out each&amp;nbsp; layer with a new 3DView or some other class. How they interact is still some I am playing with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We will figure this out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="139602" class="image-1 jive-image" height="346" src="https://community.esri.com/legacyfs/online/139602_pastedImage_0.png" style="max-width: 1200px; max-height: 900px; width: 685px; height: 345.701px;" width="685" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 16:24:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493609#M6677</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-11-06T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493610#M6678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey guys, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached is an example of how to turn off and on the layer visibility.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To test it make a layer named "TestLayer". The sample actually turns it off, and then back on again. And prints the current state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you have further questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 18:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493610#M6678</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-11-06T18:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493611#M6679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Chris. Will let you know how it goes later tonight. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully now I will have 200 cross sections webscenes, and 200 snap shots XD. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2015 19:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493611#M6679</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-11-06T19:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493612#M6680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The example works for the layers, thanks. However I'm trying to use the visibility in conjunction with an occlusion query. Turning layer visibility off or deleting the model doesn't keep the touches() function from triggering. Only when I don't generate a model through its rule (like case visible == true: extrude(5), else: NIL) does the query work as expected. Should I just give all the objects from the layer a visibility attribute (ce.setAttribute) and change that to false with python before generating or is there a proper way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="diff.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/173800_diff.png" style="width: 620px; height: 1161px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jan 2016 12:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493612#M6680</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2016-01-27T12:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493613#M6681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey ZR, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ohhh, so you want to toggle visibility on the procedural model level. &lt;BR /&gt;I think you have few options here. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For one, NIL will not generate geometry so the occlusion functions may not work (not entirely sure on that). What might be as helpful is the parameter approach you suggested toggling the &lt;A href="http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/cgareference/attr_material.html"&gt;material.opacity&lt;/A&gt; attribute.&amp;nbsp; By toggling this attribute between 1-0 and setting the attribute in python, you should be able to cloak your models while still setting off occlusion functions. Thus this way you get the same effect, without turning off the entire layer. Also you can change the shape attributes opacity ANYWHERE in the shape hierarchy allowing more nuanced control. &lt;BR /&gt;Hope this helps,&lt;BR /&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jan 2016 15:29:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493613#M6681</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2016-01-27T15:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493614#M6682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah no, I want to prevent touches() from triggering when the object is invisible. I'm almost there (?) however I have a little problem. How do I select the appropriate objects? The current code sets the visibility properly but also every object's "generate" to true. I figured there'd be a "select objects by layer name" but I can't find anything. Also how do I set a boolean value as attribute? My true/false isn't a "real" true/false, so I'm not getting a on/off slider.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a screenshot for clarification. Larger cubes: contents of Layer01-04. The cubes have a case for extrusion or NIL, depending on their "generate" attribute. The purple cubes use a rule with the touches() query. The idea is that invisible cubes don't trigger the purple ones.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="touch.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/175059_touch.png" style="width: 620px; height: 296px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from scripting import *


# List of visible layers
LayerName = ["Layer01", "Layer02", "Touches"]


ce = CE()


@noUIupdate
def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = ce.getObjectsFrom(ce.scene, ce.isLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for layer in layers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(layer) in LayerName:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisible(True)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shape in shapes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(shape, 'generate', 'true')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #ce.setAttribute(shape, 'generate', 'false')


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shape in shapes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(shape, 'generate', 'false')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisible(False) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #ce.generateModels(shapes)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #ce.waitForUIIdle()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:43:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493614#M6682</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2021-12-11T21:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493615#M6683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh got it. Sorry I misunderstood. The opacity method works assuming you still want occlusions to trigger. Now that I see your python script I understand. I think part of the problem is you are iterating through shapes without using a "getObjectsFrom" function. It might help with accessing the objects in question (shapes). &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for layer in layers: #for loop iterates through all objects in scene
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Checking objects in layer ", layer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objectList=ce.getObjectsFrom(layer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for object in objectList:&lt;/PRE&gt;&lt;P&gt;Another part is I am not sure you want to set the attribute equal to the string "true" or "false", does the rule attribute in your rule take a boolean on or a string for triggering? Because now you are passing it is string it seems. Your rule might have to recognize it as a string. &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# So if it is boolean:
case generate:Rule
else: NIL
# If it is a string:
case generate=="true":Rule
else:NIL&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Hope this helps with your python code. I see the issue has to do with the layers interaction. I think one question I have is have you just tried deleting and then reinserting the layer again if you need it? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:43:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493615#M6683</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2021-12-11T21:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493616#M6684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've not read every post in this thread, but if it helps:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Layer visibility will not affect occlusion functions&lt;/STRONG&gt;. So if you have models generated on a layer that is not visible, those models will still be included in occlusion tests. I'm 98.6 percent sure of this, unless it was changed in 2015.2, and I see nothing in the change log about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 20:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493616#M6684</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2016-01-29T20:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493617#M6685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was not sure on this point Chris, thanks (my uncertainty is why I suggested deleting the layer entirely). From Z R's post it seems that different layers can set off occlusion functions, so I guess my question is would deleting the layer entirely work? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 20:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493617#M6685</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2016-01-29T20:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493618#M6686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I think I got it now. I built two layer lists and used them to set the right attributes for the objects in the layer groups.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The rule accepts true/false as text because I changed it to do so since I couldn't figure out how to set a boolean true/false &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;. However it still would be nice to set the right attribute type. Deleting the layers isn't feasible, they have to stick around for quick comparisons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the code, maybe someone else will find it useful:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from scripting import *


# List of visible Layers
VisibleLayersNames = ["Scene Light", "Panorama", "Layer01", "Layer03", "Touches"]


VisibleLayers = []
InvisibleLayers = []
AllLayerNames = []


ce = CE()


@noUIupdate
def main():


&amp;nbsp;&amp;nbsp;&amp;nbsp; # get visible layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(len(VisibleLayersNames)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisibleLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName(VisibleLayersNames&lt;I&gt;))&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisibleLayers.extend(VisibleLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # get all layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; AllLayers = ce.getObjectsFrom(ce.scene, ce.isLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #get all layer names
&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in range(len(AllLayers)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LayerName =&amp;nbsp; ce.getName(AllLayers&lt;J&gt;)&lt;/J&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AllLayerNames.append(LayerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # set layer visibility
&amp;nbsp;&amp;nbsp;&amp;nbsp; for Layer in AllLayers:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(Layer) in VisibleLayersNames:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer.setVisible(True)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer.setVisible(False)&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # get invisible layer names
&amp;nbsp;&amp;nbsp;&amp;nbsp; InvisibleLayersNames = list(set(AllLayerNames).difference(set(VisibleLayersNames)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # get invisible layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; for k in range(len(InvisibleLayersNames)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvisibleLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName(InvisibleLayersNames&lt;K&gt;))&lt;/K&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvisibleLayers.extend(InvisibleLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # set generate attribute for visible layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; for VisibleLayer in VisibleLayers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisibleObjects=ce.getObjectsFrom(VisibleLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for VisibleObject in VisibleObjects: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(VisibleObject, 'generate', 'true')
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # set generate attribute for invisible layers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for InvisibleLayer in InvisibleLayers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvisibleObjects=ce.getObjectsFrom(InvisibleLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for InvisibleObject in InvisibleObjects: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(InvisibleObject, 'generate', 'false')
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:43:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493618#M6686</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2021-12-11T21:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493619#M6687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey ZR,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad you got it to pass correctly. The interaction between different data types between languages, GIS, and CGA/CityEngine can be tricky.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493619#M6687</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2016-02-01T18:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493620#M6688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dang, it's still not 100% right. The buildings don't generate if the models are deleted. I tried putting &lt;STRONG&gt;ce.generateModels(VisibleObjects)&lt;/STRONG&gt; under the block at line 48 (# set generate attribute for visible layers), but running the code just locks up CE. Any idea why that might be?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 00:30:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493620#M6688</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2016-02-17T00:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493621#M6689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try putting them in a valid selection and then passing the selection first, then hit generate on it rather than the layer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;ce.&lt;/SPAN&gt;&lt;A href="http://cehelp.esri.com/help/topic/com.procedural.cityengine.help/html/manual/python/jscripting/jscripting.CE.html#CE-generateModels" style="color: #007c00; text-decoration: underline; font-family: monospace;"&gt;generateModels&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;(ce.&lt;/SPAN&gt;&lt;A href="http://cehelp.esri.com/help/topic/com.procedural.cityengine.help/html/manual/python/jscripting/jscripting.CE.html#CE-selection" style="color: #007c00; text-decoration: underline; font-family: monospace;"&gt;selection&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;())&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 01:57:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493621#M6689</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2016-02-17T01:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493622#M6690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;Thanks for linking the reference, I completely forgot about the options. Setting synchronous to false did the trick.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 10:04:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493622#M6690</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2016-02-17T10:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493623#M6691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That makes sense actually. Other parameters would have been next on the list, but considering your context synchronous to false makes sense. Care to share a gif of the result? I am curious of the end result?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 15:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493623#M6691</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2016-02-17T15:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to toggle layer or model visibility through Python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493624#M6692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here you go. I stuffed this in a loop to go through a bunch of layers and check if the models in them touch other stuff.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="onoff.gif" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190808_onoff.gif" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2016 21:00:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/any-way-to-toggle-layer-or-model-visibility/m-p/493624#M6692</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2016-03-11T21:00:41Z</dc:date>
    </item>
  </channel>
</rss>

