Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ This is a sample app demonstrates the use of parametric design to build a simple
Using this app you can parametrically generate a building structure. For each generated building structure, the environmental impact is shown as the Shadow Cost over the lifecycle of the building structure.

# App structure
This is an tree app.
This is an editor app.


73 changes: 69 additions & 4 deletions app/building/controller.py → app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,74 @@
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from viktor.parametrization import Parametrization, NumberField, OptionField

from pathlib import Path
from munch import Munch
from viktor.core import ViktorController
from viktor.geometry import Group
from viktor.views import DataGroup
from viktor.views import DataItem
from viktor.views import GeometryAndDataResult
from viktor.views import GeometryAndDataView
from .model import calculate_prices
from .model import create_building_geometries
from .model import create_ground_surface
from .parametrization import BuildingParametrization
from viktor.views import WebView
from viktor.views import WebResult
from model import calculate_prices
from model import create_building_geometries
from model import create_ground_surface

_material_options = [
"Prefab Concrete",
"Steel Composite",
"Cross-Laminated-Timber",
"CLT Composite",
]


class BuildingParametrization(Parametrization):
"""Defines the input fields in left-side of the web UI in the Building entity (Editor)."""
width = NumberField(
"Building width",
suffix="m",
default=20,
min=10,
max=30,
num_decimals=1,
variant="slider",
flex=100,
)
length = NumberField(
"Building Length",
suffix="m",
default=30,
min=20,
max=40,
num_decimals=1,
variant="slider",
flex=100,
)
floor_height = NumberField(
"Floor Height",
suffix="m",
default=3,
step=0.1,
min=2.5,
max=4.0,
num_decimals=1,
variant="slider",
flex=100,
)
floors = NumberField(
"Floors", default=3, min=1, max=10, num_decimals=1, variant="slider", flex=100
)
material = OptionField(
"Construction Material",
options=_material_options,
default="Prefab Concrete",
variant="radio",
flex=100)




class BuildingController(ViktorController):
Expand Down Expand Up @@ -79,3 +136,11 @@ def visualize(self, params: Munch, **kwargs) -> GeometryAndDataResult:
return GeometryAndDataResult(
Group([ground_surface, core, *slabs, *columns]), data
)

@WebView("What's next?", duration_guess=1)
def whats_next(self, params, **kwargs):
"""Initiates the process of rendering the "What's next" tab."""
html_path = Path(__file__).parent / "next_step.html"
with html_path.open(encoding="utf-8") as _file:
html_string = _file.read()
return WebResult(html=html_string)
22 changes: 0 additions & 22 deletions app/__init__.py

This file was deleted.

15 changes: 0 additions & 15 deletions app/building/__init__.py

This file was deleted.

67 changes: 0 additions & 67 deletions app/building/parametrization.py

This file was deleted.

74 changes: 37 additions & 37 deletions app/building/materials_and_prices.py → materials_and_prices.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
"""Copyright (c) 2021 VIKTOR B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
VIKTOR B.V. PROVIDES THIS SOFTWARE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from viktor.core import Color
from viktor.geometry import Material
SHADOW_PRICE_SLAB_PER_M2 = {
"Prefab Concrete": 12.8,
"Cross-Laminated-Timber": 0.9,
"Steel Composite": 10.2,
}
SHADOW_PRICE_COLUMN_PER_M = {
"Prefab Concrete": 17.1,
"Cross-Laminated-Timber": 0.7,
"Steel Composite": 9.0,
}
SHADOW_PRICE_CORE_PER_M2 = {
"Prefab Concrete": 6.9,
"Cross-Laminated-Timber": 0.9
}
PREFAB_CONCRETE = Material("Prefab Concrete", color=Color(220, 220, 220))
TIMBER = Material("Cross-Laminated-Timber", color=Color(250, 200, 150))
STEEL = Material("Steel Composite", color=Color(100, 100, 100))
GROUND = Material("ground green", color=Color(200, 250, 155))
"""Copyright (c) 2021 VIKTOR B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

VIKTOR B.V. PROVIDES THIS SOFTWARE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from viktor.core import Color
from viktor.geometry import Material

SHADOW_PRICE_SLAB_PER_M2 = {
"Prefab Concrete": 12.8,
"Cross-Laminated-Timber": 0.9,
"Steel Composite": 10.2,
}
SHADOW_PRICE_COLUMN_PER_M = {
"Prefab Concrete": 17.1,
"Cross-Laminated-Timber": 0.7,
"Steel Composite": 9.0,
}
SHADOW_PRICE_CORE_PER_M2 = {
"Prefab Concrete": 6.9,
"Cross-Laminated-Timber": 0.9
}

PREFAB_CONCRETE = Material("Prefab Concrete", color=Color(220, 220, 220))
TIMBER = Material("Cross-Laminated-Timber", color=Color(250, 200, 150))
STEEL = Material("Steel Composite", color=Color(100, 100, 100))
GROUND = Material("ground green", color=Color(200, 250, 155))
Loading