import requests
import json

# Load the model
response = requests.post("http://localhost:5000/api/model/load", params={ "file_path": "D:\\Temp\\BIMvision\\test_model.ifc" })
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

# Get all objects with extended information
response = requests.get("http://localhost:5000/api/objects/getObjectsExtended")
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

walls = []
not_walls = []

# Separate walls from other objects
for obj in response.json()["Data"]:
    if obj["Type"] == "IfcWall":
        walls.append(obj)
    else:
        not_walls.append(obj)

# Get IDs of walls with names starting with "SW - Ext - " (External walls)
walls_ext_ids = [ x["Id"] for x in walls if x["Name"] and x["Name"].startswith("SW - Ext - ")]
# Get IDs of non-wall objects
not_walls_ids = [x["Id"] for x in not_walls]

# Hide non-wall objects
response = requests.post("http://localhost:5000/api/objects/hide", params={ "object_ids": not_walls_ids })
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
# Select wall objects
response = requests.post("http://localhost:5000/api/objects/select", params={ "object_ids": walls_ext_ids })
print(json.dumps(response.json(), indent=2, ensure_ascii=False))