Files
IfcOpenShell/aws/lambda/example_handler/__init__.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
691 B
Python
Raw Normal View History

2023-06-10 22:49:54 +02:00
import ifcopenshell
import ifcopenshell.util.element
import boto3
s3 = boto3.resource('s3')
def handler(event, context):
print("Hello from lambda")
print("Event: {}".format(event))
print("Context: {}".format(context))
filename = event['body']['filename']
s3.Bucket('my_ifc_files').download_file(filename, f'/tmp/{filename}')
ifc_file = ifcopenshell.open(f'/tmp/{filename}')
walls = ifc_file.by_type('IfcWall')
psets = []
for wall in walls:
wall_data = ifcopenshell.util.element.get_psets(wall)
wall_data['id'] = wall.GlobalId
psets.append(wall_data)
return {
'statusCode': 200,
'body': psets
}