Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Esri/pyprt-examples
Examples for PyPRT (Python bindings for CityEngine Procedural Runtime).
https://github.com/Esri/pyprt-examples
arcgis architecture cga cityengine esri examples gis pyprt python python3
Last synced: 3 days ago
JSON representation
Examples for PyPRT (Python bindings for CityEngine Procedural Runtime).
- Host: GitHub
- URL: https://github.com/Esri/pyprt-examples
- Owner: Esri
- License: apache-2.0
- Created: 2019-12-16T17:48:28.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-18T14:09:07.000Z (4 months ago)
- Last Synced: 2024-08-25T00:56:07.116Z (2 months ago)
- Topics: arcgis, architecture, cga, cityengine, esri, examples, gis, pyprt, python, python3
- Language: Python
- Homepage: https://esri.github.io/cityengine/pyprt
- Size: 54.3 MB
- Stars: 30
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-arcgis-developers - Esri/pyprt-examples - Example for PyPRT (Python Bindings for the CityEngine SDK). (Code samples and snippets)
README
# PyPRT Examples
PyPRT provides a Python binding for the [CityEngine Procedural RunTime (PRT)](https://github.com/esri/cityengine-sdk). This enables the execution of CityEngine CGA rules within Python. PyPRT allows to easily and efficiently generate 3D geometries, process them as Python data structures and export them to [multiple 3D file formats](https://esri.github.io/cityengine-sdk/html/esri_prt_codecs.html).
This repo contains examples of PyPRT usage. You can find installation instructions and the source code in the main [PyPRT](https://github.com/Esri/pyprt) repository.
## Table of Contents
* [Requirements](#requirements)
* [Running the Examples](#running-the-examples)
* [Available Examples](#available-examples)
* [Provided Rule Packages](#provided-rule-packages)
* [Licensing Information](#licensing-information)### More Documentation
* [Built-In PRT Encoders and Options](https://esri.github.io/cityengine-sdk/html/esri_prt_codecs.html)
* [Authoring of Rule Packages in CityEngine](https://doc.arcgis.com/en/cityengine/latest/help/help-rule-package.htm#ESRI_SECTION1_F9D4CCCE0EC74E5FB646A8BD141A38F9)
* [CityEngine SDK (PRT) C++ API Reference](https://esri.github.io/cityengine-sdk/html/index.html)## Requirements
* Windows 10/11 64bit or Linux 64bit (RHEL 8/9 and compatible distributions)
* Python 3.8 64bit or later. Please note, we currently provide PyPRT builds for Python 3.8, 3.9, 3.10 and 3.11. For other Python versions, please [build](https://github.com/Esri/pyprt) PyPRT yourself.
* Required Python packages: see `envs` directory## Running the examples
PyPRT can be installed with `pip install pyprt` or `conda install -c esri pyprt`. To run the examples a few more packages are required, so please read on! :-)
### Using virtualenv and pip
1. Open a shell and change to the root of this example repository.
1. First time setup:
1. Create a virtualenv: `python3.8 -m venv .venv` (replace `python3.8` with path to desired Python version if necessary)
1. Update to latest `pip`:
* Linux: `.venv/bin/python -m pip install --upgrade pip`
* Windows: `.venv\Scripts\python -m pip install --upgrade pip`
1. Update to latest `wheel`:
* Linux: `.venv/bin/python -m pip install --upgrade wheel`
* Windows: `.venv\Scripts\python -m pip install --upgrade wheel`
1. Install required packages for the example - this will fetch PyPRT from PyPI and all packages necessary to run the examples (replace `py38` with the used Python version):
* Linux: `.venv/bin/python -m pip install -r envs/linux/requirements-py38.txt`
* Windows: `.venv\Scripts\python -m pip install -r envs\windows\requirements-py38.txt`
1. Activate the environment:
* Linux: `source .venv/bin/activate`
* Windows: `.venv\Scripts\activate.bat`
1. Now run the examples, e.g. `python ex1_python_encoder.py`
1. For the examples based on Jupyter Notebooks, first start jupyter with `jupyter notebook` and then open the desired example notebook in the opened browser window.### Alternative: using Anaconda
1. Open the Anaconda prompt and change to the directory where you checked out this repository.
1. Ensure you have a working Anaconda Python 64bit installation, e.g. for Python 3.8.
1. Run `conda env create --prefix env --file envs/environment-py38.yml` to install PyPRT and all dependencies for the examples (replace `py38` with the used Python version).
* In case `conda env create` takes very long or runs into errors, try to remove `arcgis` from `environment-pyXX.yml` and manually call `conda install --prefix env -c esri arcgis`.
1. Activate the Anaconda environment: `conda activate ./env`
1. Now run e.g. `python ex1_python_encoder.py` to execute the corresponding Python script. For the examples based on Jupyter Notebooks, first run `jupyter notebook` and open the desired example notebook in the opening browser page.### In case of issues with Jupyter Notebook
* If the map widgets in e.g. example 8 do not show up, try to [manually enable](https://developers.arcgis.com/python/guide/install-and-set-up/#install-offline) the corresponding notebook extensions:
* `jupyter nbextension enable --py --sys-prefix widgetsnbextension`
* `jupyter nbextension enable --py --sys-prefix arcgis`
* If the notebook examples do not open correctly in a Conda environment, try to run `conda update --all` before running `jupyter notebook`. This will make sure the packages are up-to-date.## Available Examples
#
Features
Notes
1
This example shows the use of the Python encoder and the encoder options for generating (or not) geometries and CGA reports.
2
This example demonstrates the use of an OBJ file as initial shape.
3
In this example, the generated models are exported as OBJ files using the PRT OBJ exporter.
4
This example shows the two ways of calling the generate_model function in case of multiple successive geometry generations.
5
This example demonstrates how PyPRT can be used to collect a dataset stored as pandas dataframe, using the PyEncoder options.
6
In this examples, VisPy is used as a mesh visualization tool taking PyPRT generated model (vertices and faces) as input.
7
This example is about optimizing the attributes of a building generated on a parcel considering the green area of the building. SciPy is used as the optimization library.
PyVista is used as a visualization tool in this example.
8
This example demonstrates how PyPRT can be used with the ArcGIS API for Python in order to collect data from ArcGIS Online, generate 3D content and publish the content back to ArcGIS Online.
Please note that in order to publish and visualize the generated models, the user needs an ArcGIS Developer account. Also, the published item needs to be manually deleted from the ArcGIS Online account before the example script can be run again (we do not want to delete things from your account).
9
In this example, PyPRT is used as a 3D geometry converter. Using PyPRT, the ArcGIS JavaScript API and the ArcGIS API for Python, you can visualize your 3D model on a map in the Web.
Please note that in order to publish and visualize the generated models, the user needs an ArcGIS Online account. To try the example, run
python ex9_model_vis_web.py --username=my_AGO_username
in your Python environment.
10
This example demonstrates how an existing Scene Layer can be updated without having to touch any related Web Scenes. We use PyPRT to create a Scene Layer with a 3d visualization of the Swiss population density. We then recreate the Scene Layer with different visualization properties and show how the Web Scene updates automatically.
You might want to use the keyring package to store your credentials for arcgis.com. The example script will automatically pick them up.
To store the credentials execute the following once in a terminal:$ python
>>> import keyring
>>> keyring.set_password("arcgis.com",
"your_user", "your_password")
## Provided Rule Packages
Rule Package
Shape Attributes
Attributes Default Values
Brief Description
candler.rpk
BuildingHeight
Mode
FloorHeight
GroundfloorHeight
TileWidth
CorniceOverhang
WindowHeight
FrontWindowWidth
RearWindowWidth
SillSize
CornerWallWidth
WallTexture
ColorizeWall
62.0
"Visualization"
3.5
4.3
3.55
1.2
2.05
2.15
1.2
0.26
1.0
"facade/walls/bricks.jpg"
"#FCEFE2"
Allows generating a "candler" building model, which is textured, detailed and realistic.
envelope2002.rpk
Density_bonus_height
shape_of_building
lot_coverage_parameter
height_first_tier
first_setback_size
height_second_tier
second_setback_size
ground_floors_use
main_building_use
create_green_spaces
report_but_not_display_green
etc...
60.0
1.0
60.0
12.2
3.0
40.0
3.0
"commercial"
"residential"
false
false
etc...
Allows generating a realistic and detailed building.
extrusion_rule.rpk
minBuildingHeight
maxBuildingHeight
buildingColor
OBJECTID
text
10.0
30.0
"#FF00FF"
0.0
"salut"
Performs a simple extrusion of the initial shape with a height equals to a random number between the min and maxBuildingHeight.
noRule.rpk
Performs the identity operation.
translateModel.rpk
vec_x
vec_y
vec_z
0.0
0.0
0.0
Allows translating the initial shape in x, y and z directions.
## Licensing Information
PyPRT is free for personal, educational, and non-commercial use. Commercial use requires at least one commercial license of the latest CityEngine version installed in the organization. Redistribution or web service offerings are not allowed unless expressly permitted.
PyPRT is under the same license as the included [CityEngine SDK](https://github.com/esri/cityengine-sdk#licensing). An exception is the PyPRT source code (without CityEngine SDK, binaries, or object code), which is licensed under the Apache License, Version 2.0 (the “License”); you may not use this work except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.
All content in the "Examples" directory/section is licensed under the APACHE 2.0 license as well.
For questions or enquiries, please contact the Esri CityEngine team ([email protected]).
[Back to top](#table-of-contents)
[Go to source code](https://github.com/Esri/pyprt)