{"id":13505516,"url":"https://github.com/Esri/pyprt-examples","last_synced_at":"2025-03-30T00:31:07.833Z","repository":{"id":37218039,"uuid":"228442836","full_name":"Esri/pyprt-examples","owner":"Esri","description":"Examples for PyPRT (Python bindings for CityEngine Procedural Runtime).","archived":false,"fork":false,"pushed_at":"2025-03-13T17:13:22.000Z","size":57083,"stargazers_count":33,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T02:08:17.053Z","etag":null,"topics":["arcgis","architecture","cga","cityengine","esri","examples","gis","pyprt","python","python3"],"latest_commit_sha":null,"homepage":"https://esri.github.io/cityengine/pyprt","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Esri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-16T17:48:28.000Z","updated_at":"2025-03-13T17:12:21.000Z","dependencies_parsed_at":"2024-01-08T09:04:12.375Z","dependency_job_id":"792a0a4c-f09b-4604-9deb-fbb40ca6d4ef","html_url":"https://github.com/Esri/pyprt-examples","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Esri%2Fpyprt-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Esri%2Fpyprt-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Esri%2Fpyprt-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Esri%2Fpyprt-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Esri","download_url":"https://codeload.github.com/Esri/pyprt-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arcgis","architecture","cga","cityengine","esri","examples","gis","pyprt","python","python3"],"created_at":"2024-08-01T00:01:09.295Z","updated_at":"2025-03-30T00:31:02.826Z","avatar_url":"https://github.com/Esri.png","language":"Jupyter Notebook","funding_links":[],"categories":["Code samples and snippets"],"sub_categories":[],"readme":"# PyPRT Examples\n\n\u003cimg align=\"left\" alt=\"PyPRT Icon\" width=\"40px\" src=\"images/pyprt_logo.png\" /\u003e\n\nPyPRT 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).\n\nThis 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.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"images/building.png\" alt=\"green building\" /\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"images/generated_trees.png\" alt=\"city with trees\" /\u003e\u003c/p\u003e\n\n## Table of Contents\n\n* [Requirements](#requirements)\n* [Running the Examples](#running-the-examples)\n* [Available Examples](#available-examples)\n* [Provided Rule Packages](#provided-rule-packages)\n* [Licensing Information](#licensing-information)\n\n### More Documentation\n  * [Built-In PRT Encoders and Options](https://esri.github.io/cityengine-sdk/html/esri_prt_codecs.html)\n  * [Authoring of Rule Packages in CityEngine](https://doc.arcgis.com/en/cityengine/latest/help/help-rule-package.htm#ESRI_SECTION1_F9D4CCCE0EC74E5FB646A8BD141A38F9)\n  * [CityEngine SDK (PRT) C++ API Reference](https://esri.github.io/cityengine-sdk/html/index.html)\n\n## Requirements\n\n* Windows 10/11 64bit or Linux 64bit (RHEL 8/9 and compatible distributions)\n* 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.\n* Required Python packages: see `envs` directory\n\n## Running the examples\n\nPyPRT 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! :-)\n\n### Using virtualenv and pip\n\n1. Open a shell and change to the root of this example repository.\n1. First time setup:\n   1. Create a virtualenv: `python3.8 -m venv .venv` (replace `python3.8` with path to desired Python version if necessary)\n   1. Update to latest `pip`:\n      * Linux: `.venv/bin/python -m pip install --upgrade pip`\n      * Windows: `.venv\\Scripts\\python -m pip install --upgrade pip`\n    1. Update to latest `wheel`:\n      * Linux: `.venv/bin/python -m pip install --upgrade wheel`\n      * Windows: `.venv\\Scripts\\python -m pip install --upgrade wheel`\n   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):\n      * Linux: `.venv/bin/python -m pip install -r envs/linux/requirements-py38.txt`\n      * Windows: `.venv\\Scripts\\python -m pip install -r envs\\windows\\requirements-py38.txt`\n1. Activate the environment:\n   * Linux: `source .venv/bin/activate`\n   * Windows: `.venv\\Scripts\\activate.bat`\n1. Now run the examples, e.g. `python ex1_python_encoder.py` \n1. 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.\n\n### Alternative: using Anaconda\n\n1. Open the Anaconda prompt and change to the directory where you checked out this repository.\n1. Ensure you have a working Anaconda Python 64bit installation, e.g. for Python 3.8.\n1. 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).\n   * 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`. \n1. Activate the Anaconda environment: `conda activate ./env`\n1. 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.\n\n### In case of issues with Jupyter Notebook\n* 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:\n   * `jupyter nbextension enable --py --sys-prefix widgetsnbextension`\n   * `jupyter nbextension enable --py --sys-prefix arcgis`\n* 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.\n\n## Available Examples\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003e#\u003c/th\u003e\n    \u003cth\u003eFeatures\u003c/th\u003e \n    \u003cth\u003eNotes\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e1\u003c/td\u003e\n    \u003ctd\u003eThis example shows the use of the Python encoder and the encoder options for generating (or not) geometries and CGA reports. \u003c/td\u003e\n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e2\u003c/td\u003e\n    \u003ctd\u003eThis example demonstrates the use of an OBJ file as initial shape.\u003c/td\u003e\n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e3\u003c/td\u003e\n    \u003ctd\u003eIn this example, the generated models are exported as OBJ files using the PRT OBJ exporter.\u003c/td\u003e\n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e4\u003c/td\u003e\n    \u003ctd\u003eThis example shows the two ways of calling the generate_model function in case of multiple successive geometry generations.\u003c/td\u003e \n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e5\u003c/td\u003e\n    \u003ctd\u003eThis example demonstrates how PyPRT can be used to collect a dataset stored as pandas dataframe, using the PyEncoder options.\u003c/td\u003e\n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e6\u003c/td\u003e\n    \u003ctd\u003eIn this examples, VisPy is used as a mesh visualization tool taking PyPRT generated model (vertices and faces) as input.\u003c/td\u003e\n    \u003ctd\u003e \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e7\u003c/td\u003e\n    \u003ctd\u003eThis 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.\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://docs.pyvista.org/\"\u003ePyVista\u003c/a\u003e is used as a visualization tool in this example.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e8\u003c/td\u003e\n    \u003ctd\u003eThis example demonstrates how PyPRT can be used with the \u003ca href=\"https://developers.arcgis.com/python/\"\u003eArcGIS API for Python\u003c/a\u003e in order to collect data from \u003ca href=\"https://www.esri.com/en-us/arcgis/products/arcgis-online/overview\"\u003eArcGIS Online\u003c/a\u003e, generate 3D content and publish the content back to ArcGIS Online.\u003c/td\u003e\n    \u003ctd\u003ePlease note that in order to publish and visualize the generated models, the user needs an \u003ca href=\"https://developers.arcgis.com/\"\u003eArcGIS Developer account\u003c/a\u003e. 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).\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e9\u003c/td\u003e\n    \u003ctd\u003eIn this example, PyPRT is used as a 3D geometry converter. Using PyPRT, the \u003ca href=\"https://developers.arcgis.com/javascript/\"\u003eArcGIS JavaScript API\u003c/a\u003e and the \u003ca href=\"https://developers.arcgis.com/python/\"\u003eArcGIS API for Python\u003c/a\u003e, you can visualize your 3D model on a map in the Web.\u003c/td\u003e\n    \u003ctd\u003ePlease note that in order to publish and visualize the generated models, the user needs an \u003ca href=\"https://www.esri.com/en-us/arcgis/products/create-account\"\u003eArcGIS Online account\u003c/a\u003e. To try the example, run\n\t  \u003ccode\u003e\n\t    python ex9_model_vis_web.py --username=my_AGO_username\n      \u003c/code\u003e\n\t  in your Python environment.\n\t\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e10\u003c/td\u003e\n    \u003ctd\u003eThis 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.\u003c/td\u003e\n    \u003ctd\u003eYou might want to use the keyring package to store your credentials for arcgis.com. The example script will automatically pick them up.\u003cbr/\u003eTo store the credentials execute the following once in a terminal:\u003cpre\u003e$ python\n\u003e\u003e\u003e import keyring\n\u003e\u003e\u003e keyring.set_password(\"arcgis.com\",\n      \"your_user\", \"your_password\")\u003c/pre\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Provided Rule Packages\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003eRule Package\u003c/th\u003e\n    \u003cth\u003eShape Attributes\u003c/th\u003e\n\t\u003cth\u003eAttributes Default Values\u003c/th\u003e\n    \u003cth\u003eBrief Description\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ecandler.rpk\u003c/td\u003e\n    \u003ctd\u003eBuildingHeight\u003cbr/\u003e\n\t\tMode\u003cbr/\u003e\n\t\tFloorHeight\u003cbr/\u003e\n\t\tGroundfloorHeight\u003cbr/\u003e\n\t\tTileWidth\u003cbr/\u003e\n\t\tCorniceOverhang\u003cbr/\u003e\n\t\tWindowHeight\u003cbr/\u003e\n\t\tFrontWindowWidth\u003cbr/\u003e\n\t\tRearWindowWidth\u003cbr/\u003e\n\t\tSillSize\u003cbr/\u003e\n\t\tCornerWallWidth\u003cbr/\u003e\n\t\tWallTexture\u003cbr/\u003e\n\t\tColorizeWall\u003c/td\u003e\n\t\u003ctd\u003e62.0\u003cbr/\u003e\n\t\t\"Visualization\"\u003cbr/\u003e\n\t\t3.5\u003cbr/\u003e\n\t\t4.3\u003cbr/\u003e\n\t\t3.55\u003cbr/\u003e\n\t\t1.2\u003cbr/\u003e\n\t\t2.05\u003cbr/\u003e\n\t\t2.15\u003cbr/\u003e\n\t\t1.2\u003cbr/\u003e\n\t\t0.26\u003cbr/\u003e\n\t\t1.0\u003cbr/\u003e\n\t\t\"facade/walls/bricks.jpg\"\u003cbr/\u003e\n\t\t\"#FCEFE2\"\u003c/td\u003e\n    \u003ctd\u003eAllows generating a \"candler\" building model, which is textured, detailed and realistic.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eenvelope2002.rpk\u003c/td\u003e\n    \u003ctd\u003eDensity_bonus_height\u003cbr/\u003e\n\t\tshape_of_building\u003cbr/\u003e\n\t\tlot_coverage_parameter\u003cbr/\u003e\n\t\theight_first_tier\u003cbr/\u003e\n\t\tfirst_setback_size\u003cbr/\u003e\n\t\theight_second_tier\u003cbr/\u003e\n\t\tsecond_setback_size\u003cbr/\u003e\n\t\tground_floors_use\u003cbr/\u003e\n\t\tmain_building_use\u003cbr/\u003e\n\t\tcreate_green_spaces\u003cbr/\u003e\n\t\treport_but_not_display_green\u003cbr/\u003e\n\t\tetc...\u003c/td\u003e\n\t\u003ctd\u003e60.0\u003cbr/\u003e\n\t\t1.0\u003cbr/\u003e\n\t\t60.0\u003cbr/\u003e\n\t\t12.2\u003cbr/\u003e\n\t\t3.0\u003cbr/\u003e\n\t\t40.0\u003cbr/\u003e\n\t\t3.0\u003cbr/\u003e\n\t\t\"commercial\"\u003cbr/\u003e\n\t\t\"residential\"\u003cbr/\u003e\n\t\tfalse\u003cbr/\u003e\n\t\tfalse\u003cbr/\u003e\n\t\tetc...\u003c/td\u003e\n    \u003ctd\u003eAllows generating a realistic and detailed building.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eextrusion_rule.rpk\u003c/td\u003e\n    \u003ctd\u003eminBuildingHeight\u003cbr/\u003e\n\t\tmaxBuildingHeight\u003cbr/\u003e\n\t\tbuildingColor\u003cbr/\u003e\n\t\tOBJECTID\u003cbr/\u003e\n\t\ttext\u003c/td\u003e\n\t\u003ctd\u003e10.0\u003cbr/\u003e\n\t\t30.0\u003cbr/\u003e\n\t\t\"#FF00FF\"\u003cbr/\u003e\n\t\t0.0\u003cbr/\u003e\n\t\t\"salut\"\u003c/td\u003e\n    \u003ctd\u003ePerforms a simple extrusion of the initial shape with a height equals to a random number between the min and maxBuildingHeight.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003enoRule.rpk\u003c/td\u003e\n    \u003ctd/\u003e\n\t\u003ctd/\u003e\n    \u003ctd\u003ePerforms the identity operation.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003etranslateModel.rpk\u003c/td\u003e\n    \u003ctd\u003evec_x\u003cbr/\u003e\n\t\tvec_y\u003cbr/\u003e\n\t\tvec_z\u003c/td\u003e\n\t\u003ctd\u003e0.0\u003cbr/\u003e\n\t\t0.0\u003cbr/\u003e\n\t\t0.0\u003c/td\u003e\n    \u003ctd\u003eAllows translating the initial shape in x, y and z directions.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Licensing Information\n\nPyPRT 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.\n\nPyPRT 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.\n\nAll content in the \"Examples\" directory/section is licensed under the APACHE 2.0 license as well.\n\nFor questions or enquiries, please contact the Esri CityEngine team (cityengine-info@esri.com).\n\n[Back to top](#table-of-contents)\n\n[Go to source code](https://github.com/Esri/pyprt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEsri%2Fpyprt-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEsri%2Fpyprt-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEsri%2Fpyprt-examples/lists"}