ldverify.py

Wed, 20 Dec 2017 17:25:09 +0200

author
Santeri Piippo
date
Wed, 20 Dec 2017 17:25:09 +0200
changeset 6
6da1e81c5652
parent 3
1dc58f44d556
child 7
0ab0d61ccee8
permissions
-rwxr-xr-x

Added code to compute areas of triangles and quadrilaterals

#!/usr/bin/env python3
from parse import parse_ldraw_code

def read_ldraw(file, *, libraries):
    result = list()
    for line in file:
        result.append(parse_ldraw_code(line))
    return result

if __name__ == '__main__':
    from sys import argv
    libraries = [{'path': '/home/teemu/ldraw', 'role': 'official'}]
    with open(argv[1], 'r') as file:
        model = read_ldraw(file, libraries = libraries)
        for entry in model:
            if hasattr(entry, 'geometry') and len(entry.geometry) >= 3:
                print(repr(entry))
                print(entry.geometry.area())
            #print(entry.textual_representation().strip(), end = '\r\n')

mercurial