Select to view content in your preferred language

Any way to toggle layer or model visibility through Python?

5467
18
10-07-2015 06:31 AM
LR
by
Frequent Contributor

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?

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.

Tags (2)
18 Replies
LR
by
Frequent Contributor

Dang, it's still not 100% right. The buildings don't generate if the models are deleted. I tried putting ce.generateModels(VisibleObjects) 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?

0 Kudos
DavidWasserman
Frequent Contributor

Try putting them in a valid selection and then passing the selection first, then hit generate on it rather than the layer.

ce.generateModels(ce.selection())

David Wasserman, AICP
LR
by
Frequent Contributor

Thanks for linking the reference, I completely forgot about the options. Setting synchronous to false did the trick.

0 Kudos
DavidWasserman
Frequent Contributor

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?

David Wasserman, AICP
0 Kudos
LR
by
Frequent Contributor

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.

onoff.gif

by Anonymous User
Not applicable

ZR, This is a CityEngine python question, and not an ArcPy question, right? Just clarifying for Ben.

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.

Chris

DavidWasserman
Frequent Contributor

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  layer with a new 3DView or some other class. How they interact is still some I am playing with.

We will figure this out.

David Wasserman, AICP
0 Kudos
by Anonymous User
Not applicable

Hey guys,

Attached is an example of how to turn off and on the layer visibility.

To test it make a layer named "TestLayer". The sample actually turns it off, and then back on again. And prints the current state.

Let me know if you have further questions.

Chris

DavidWasserman
Frequent Contributor

Thanks Chris. Will let you know how it goes later tonight.

Hopefully now I will have 200 cross sections webscenes, and 200 snap shots XD.

David Wasserman, AICP
0 Kudos