Is it possible to develop a window like Dashboard in CityEngine

1542
6
Jump to solution
10-11-2016 01:34 AM
HangyuChen
New Contributor II

Hello guys,

    I try to run a simulation cooperating with CGA and Python Script, I need a window which is dialog like Dashboard to input parameter before starting and visualize results (by giving values or figure) in it. One way I found is that Py script in CE can use swing library to develop graphic user interface but it seems to be outside CE I afraid it will be problem later with developing. Another way I wonder is it possible to develop a window inside CE via Python (or SDK)

   Actually I major in urban planning, not familiar with programming so i just ask for some professional advice which way is better? it is my main question.

two small "question":

  1. we can get object value as HELP said. so for one base we can get streetWidth value around the base, is it possible to give the elevation around it?

  2. Web Scene Viewer is quite good for design display but it can only change layer. is it possible to generate user mode where users can adjust attribute we defined and see results dynamically, but users don't need to see CGA editor and some more??

THANKS!

CHEN

0 Kudos
1 Solution

Accepted Solutions
LR
by
Regular Contributor

Here's a small example. It spawns a window with a text field and a button, when you press the button, the text field content is printed in the CE Python console.

from scripting import *
from javax.swing import *
from java.awt import *

def spawnUI():
frame = JFrame("Hell World!")
 frame.setSize(300, 300)
 frame.locationRelativeTo=None
 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
 
 pnl = JPanel(GridLayout(0,2,5,5))
 frame.add(pnl) 
 
 global txt_input
 txt_input = JTextField('',15)
 pnl.add(txt_input)

 btn_run = JButton('Print!',actionPerformed=runAction)
 pnl.add(btn_run)
 
 frame.pack()
 frame.setVisible(True)
 
def runAction(event):
 print(txt_input.text)
 
# get a CityEngine instance
ce = CE()

if __name__ == '__main__':
 spawnUI()

View solution in original post

0 Kudos
6 Replies
LR
by
Regular Contributor

I haven't been able to go further than swing, but I never really needed to - you can write and read values to/from the UI which is all I really need for my scripts. I doubt it's possible anyway. I tried hijacking some CE windows a while ago but the random SWT window naming that didn't even stay consistent within a program session wasn't exactly helping.

0 Kudos
HangyuChen
New Contributor II

Hi LR,

  Thanks for reply... So do you know any method to develop that "window" in CE?

And one more question, how to use the tirm operation, trim() ?

Thanks!

CHEN

0 Kudos
LR
by
Regular Contributor

Here's a small example. It spawns a window with a text field and a button, when you press the button, the text field content is printed in the CE Python console.

from scripting import *
from javax.swing import *
from java.awt import *

def spawnUI():
frame = JFrame("Hell World!")
 frame.setSize(300, 300)
 frame.locationRelativeTo=None
 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
 
 pnl = JPanel(GridLayout(0,2,5,5))
 frame.add(pnl) 
 
 global txt_input
 txt_input = JTextField('',15)
 pnl.add(txt_input)

 btn_run = JButton('Print!',actionPerformed=runAction)
 pnl.add(btn_run)
 
 frame.pack()
 frame.setVisible(True)
 
def runAction(event):
 print(txt_input.text)
 
# get a CityEngine instance
ce = CE()

if __name__ == '__main__':
 spawnUI()
0 Kudos
HangyuChen
New Contributor II

Thanks! LR

I might go by this way

0 Kudos
CherylLau
Esri Regular Contributor

You can open other applications using python and pass parameters to them.  For example, this opens notepad.exe:

import subprocess
subprocess.Popen('start notepad.exe', shell=True)

This opens notepad.exe with another filename as an argument:

subprocess.Popen('start notepad.exe "C:\Users\<username>\Desktop\myParameters.py"', shell=True)‍‍

No, you cannot open another window within CityEngine similar to the Dashboard, but you can open other applications outside of CityEngine using the code above.

In the future, please start new GeoNet posts for new topics.  Trim planes are set on operations like comp.  This helps trim geometry like ledges that go around buildings so that they meet up correctly at the corners.  Please see the visual diagrams in the examples section called "Trim planes" on the comp help page: Component Split Operation .  To enable or disable trim planes, you can set the vertical or horizontal trim planes to true or false:  split Shape Attribute .  The trim operation will then apply the cut along the trim plane to the current geometry.

0 Kudos
HangyuChen
New Contributor II

Understood.

Thank you! Lau

0 Kudos