mass glb import
This commit is contained in:
parent
6cbb63b4e8
commit
1219204f45
Binary file not shown.
|
@ -0,0 +1,23 @@
|
||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from django.core.files import File
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
from object.models import Element3D, Scene3D
|
||||||
|
logger = logging.getLogger("root")
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
root_directory = "object/management/commands/data"
|
||||||
|
|
||||||
|
files = glob.glob("*.glb", recursive=True, root_dir=root_directory)
|
||||||
|
hv = Scene3D.objects.get(id=48)
|
||||||
|
for f in files:
|
||||||
|
with open(os.path.join(root_directory, f), 'rb') as file:
|
||||||
|
el = Element3D(name=f)
|
||||||
|
el.model_file = File(file, f)
|
||||||
|
el.save()
|
||||||
|
logger.info(el)
|
||||||
|
hv.elements.add(el)
|
||||||
|
logger.info(hv.elements.count())
|
||||||
|
|
Loading…
Reference in New Issue