move renderscad into Level model

This commit is contained in:
Laura Klünder 2017-08-06 22:07:34 +02:00
parent 7b141aa87b
commit 756c3976d0
3 changed files with 36 additions and 14 deletions

View file

@ -1,17 +1,9 @@
import os
from django.conf import settings
from django.core.management.base import BaseCommand
from c3nav.mapdata.utils.scad import polygon_scad
class Command(BaseCommand):
help = 'render the map to openscad'
def handle(self, *args, **options):
from c3nav.mapdata.models import AltitudeArea
filename = os.path.join(settings.RENDER_ROOT, 'all.scad')
with open(filename, 'w') as f:
for area in AltitudeArea.objects.all():
f.write('translate([0, 0, %.2f]) ' % area.altitude)
f.write(polygon_scad(area.geometry)+';\n')
from c3nav.mapdata.models import Level
Level.render_scad_all()