Note
Click here to download the full example code
SBR+: Import Geometry from Maps#
This example shows how you can use PyAEDT to create an HFSS SBR+ project from an OpenStreeMaps.
Perform required imports#
Perform required imports and set up the local path to the PyAEDT directory path.
import os
from pyaedt import Hfss
Set non-graphical mode#
Set non-graphical mode. "PYAEDT_NON_GRAPHICAL"
is needed to generate
documentation only.
You can set non_graphical
either to True
or False
.
non_graphical = os.getenv("PYAEDT_NON_GRAPHICAL", "False").lower() in ("true", "1", "t")
Define designs#
Define two designs, one source and one target. Each design is connected to a different object.
app = Hfss(
designname="Ansys",
solution_type="SBR+",
specified_version="2022.2",
new_desktop_session=True,
non_graphical=non_graphical
)
Define Location to import#
Define latitude and longitude to import.
ansys_home = [40.273726, -80.168269]
Generate map and import#
Assign boundaries.
app.modeler.import_from_openstreet_map(ansys_home,
terrain_radius=250,
road_step=3,
plot_before_importing=False,
import_in_aedt=True)
Creating tmp_cache
INFO:root:Retrieving https://srtm.kurviger.de/SRTM1//Region_06//N40W081.hgt.zip
INFO:root:Retrieved https://srtm.kurviger.de/SRTM1//Region_06//N40W081.hgt.zip (8459110 bytes)
DEBUG:root:Unzipping 8459110 bytes
DEBUG:root:Unzipped
4 25934402
DEBUG:root:saved 25934402 bytes in tmp_cache\N40W081.hgt
INFO:Global:
Percent Complete:####.................................... 10%
INFO:Global:
Percent Complete:########................................ 20%
INFO:Global:
Percent Complete:############............................ 30%
INFO:Global:
Percent Complete:################........................ 40%
INFO:Global:
Percent Complete:####################.................... 50%
INFO:Global:
Percent Complete:########################................ 60%
INFO:Global:
Percent Complete:############################............ 70%
INFO:Global:
Percent Complete:################################........ 80%
INFO:Global:
Percent Complete:####################################.... 90%
INFO:Global:100% - Done
INFO:Global:Processing Geometry
INFO:Global:saving STL as D:/Project/Project2337.pyaedt\Ansys/terrain.stl
INFO:Global:Generating Building Geometry
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): overpass-api.de:443
DEBUG:urllib3.connectionpool:https://overpass-api.de:443 "GET /api/status HTTP/1.1" 200 180
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): overpass-api.de:443
DEBUG:urllib3.connectionpool:https://overpass-api.de:443 "POST /api/interpreter HTTP/1.1" 200 2315
INFO:Global:
Generating Buildings
c:\actions-runner\_work\pyaedt\pyaedt\testenv\lib\site-packages\pyvista\core\filters\poly_data.py:2823: PyVistaFutureWarning: The default value of the ``capping`` keyword argument will change in a future version to ``True`` to match the behavior of VTK. We recommend passing the keyword explicitly to prevent future surprises.
warnings.warn(
INFO:Global:
Percent Complete:######################################## 100.0%
INFO:Global:Generating Road Geometry
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): overpass-api.de:443
DEBUG:urllib3.connectionpool:https://overpass-api.de:443 "GET /api/status HTTP/1.1" 200 206
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): overpass-api.de:443
DEBUG:urllib3.connectionpool:https://overpass-api.de:443 "POST /api/interpreter HTTP/1.1" 200 29457
INFO:Global:
Percent Complete:########................................ 20.0%
INFO:Global:
Percent Complete:############............................ 30.0%
INFO:Global:
Percent Complete:####################.................... 50.0%
INFO:Global:
Percent Complete:############################............ 70.0%
INFO:Global:
Percent Complete:################################........ 80.0%
INFO:Global:
Percent Complete:######################################## 100.0%
INFO:Global:Done...
INFO:Global:Step file D:/Project/Project2337.pyaedt\Ansys/terrain.stl imported
INFO:Global:Step file D:/Project/Project2337.pyaedt\Ansys\buildings.stl imported
INFO:Global:Step file D:/Project/Project2337.pyaedt\Ansys\roads.stl imported
{'name': 'default', 'version': 1, 'type': 'environment', 'center_lat_lon': [40.273726, -80.168269], 'radius': 250, 'include_buildings': True, 'include_roads': True, 'parts': {'terrain': {'file_name': 'D:/Project/Project2337.pyaedt\\Ansys/terrain.stl', 'color': 'brown', 'material': 'earth'}, 'buildings': {'file_name': 'D:/Project/Project2337.pyaedt\\Ansys\\buildings.stl', 'color': 'grey', 'material': 'concrete'}, 'roads': {'file_name': 'D:/Project/Project2337.pyaedt\\Ansys\\roads.stl', 'color': 'black', 'material': 'asphalt'}}}
Plot model#
Plot the model.
plot_obj = app.plot(show=False, plot_air_objects=True)
plot_obj.background_color = [153,203,255]
plot_obj.zoom = 1.5
plot_obj.show_grid = False
plot_obj.show_axes = False
plot_obj.bounding_box = False
plot_obj.plot(os.path.join(app.working_directory, "Source.jpg"))

True
Release AEDT#
Release AEDT and close the example.
app.release_desktop()
INFO:Global:Project files removed from handlers.
True
Total running time of the script: ( 0 minutes 47.965 seconds)