Giter Site home page Giter Site logo

pyprtdemo's Introduction

PyPRT Examples

PyPRT Icon

PyPRT provides a Python binding for PRT (Procedural RunTime) of CityEngine. 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.

This repo contains examples of PyPRT usage. You can find installation instructions and the source code in the main PyPRT repository.

green building

city with trees

Table of Contents

Requirements

  • Windows 10 64bit or Linux 64bit (RHEL7/CentOS7 compatible distro)
  • Python 3.6 64bit or later. Please note, we currently provide PyPRT builds for Python 3.6, 3.8 and 3.9 (as well as 3.7 on Windows). For other Python versions, please build PyPRT yourself.
  • Packages (see envs directory): pyprt, arcgis 1.9.0, notebook, vispy, PyQT5, scipy, PyGEL3D, tornado

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! :-)

Notes regarding Python 3.9 and Conda:

  • The arcgis package for Python 3.9 is not yet available in Conda, therefore the examples 8 and 9 are not working with Python 3.9 in a Conda environment.
  • To open the Jupyter notebook examples, run conda update --all before calling jupyter notebook in the Anaconda prompt. This will make sure the packages are up to date.

Using virtualenv and pip

  1. Open a shell and change to the root of this example repository.
  2. First time setup:
    1. Create a virtualenv: python3.8 -m venv .venv (replace python3.8 with path to desired Python version if necessary)
    2. Update to latest pip:
      • Linux: .venv/bin/python -m pip install --upgrade pip
      • Windows: .venv\Scripts\python -m pip install --upgrade pip
    3. 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
  3. Activate the environment:
    • Linux: source .venv/bin/activate
    • Windows: .venv\Scripts\activate.bat
  4. Now run the examples, e.g. python ex1_python_encoder.py
  5. 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.
  2. Ensure you have a working Anaconda Python 3.6 or 3.8 64bit installation (or additionally Python 3.7 on Windows). For other Python versions, please build PyPRT yourself at the moment.
  3. 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).
  4. Activate the Anaconda environment: conda activate ./env
  5. 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.

Available Examples

Name Features Notes
ex1_python_encoder.py This example shows the use of the Python encoder and the encoder options for generating (or not) geometries and CGA reports.
ex2_obj_initial_shape.py This example demonstrates the use of an OBJ file as initial shape.
ex3_format_exporter.py In this example, the generated models are exported as OBJ files using the PRT OBJ exporter.
ex4_multi_generations.py This example shows the two ways of calling the generate_model function in case of multiple successive geometry generations.
ex5_dataset_collection.ipynb This example demonstrates how PyPRT can be used to collect a dataset stored as pandas dataframe, using the PyEncoder options.
ex6_3d_visualization_vispy.py In this examples, VisPy is used as a mesh visualization tool taking PyPRT generated model (vertices and faces) as input.
ex7_building_modeling_optimization.ipynb 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. PyGEL3D is used as a visualization tool in this example. There is currently a known issue that the display is using the wrong up axis.
ex8_3d_gis_content_generation.ipynb 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).
ex9_model_vis_web.py 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.

Provided Rule Packages

Rule Package CGB Rule File Start Rule Shape Attributes Attributes Default Values Brief Description
candler.rpk bin/candler.cgb Default$Footprint 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 rules/typology/envelope2002.cgb Default$Lot 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 bin/extrusion_rule.cgb Default$Footprint 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 bin/noRule.cgb Default$Lot Performs the identity operation.
translateModel.rpk bin/translateModel.cgb Default$Lot 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. 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

Go to source code

pyprtdemo's People

Contributors

shenyubo1982 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.