framework/cg/pipeline/freecad_to_asset.py

42 lines
1.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
DESCRIPTION.
Convert and setup FreeCAD solid objects to 3d assets mesh files.
Support Blender compiled as a Python Module only!
"""
__version__ = "0.1"
import logging
import sys
sys.path.append('../blender/')
from import_fcstd.importer import importer
from utils.remove_collections import remove_collections
from utils.cleanup_orphan_data import cleanup_orphan_data
from remesh import asset_setup
from export.dae import export_dae
from export.collision import export_col_stl
sys.path.append('/home/bm/bin/blender-git/blender_bin') # import blender module
import bpy
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def freecad_asset_pipeline(fcstd_path, export_path, tessellation=20):
""" Setup FreeCAD scene to CG asset """
remove_collections()
cleanup_orphan_data()
importer(fcstd_path, tessellation)
asset_setup()
bpy.ops.wm.save_as_mainfile(filepath="/home/bm/test.blend")
export_dae(export_path)
export_col_stl(export_path)
if __name__ == '__main__':
fcstd_path = '/media/disk/robossembler/io-import-fcstd/test/solids.FCStd'
export_path = 'asset_generator/'
freecad_asset_pipeline(fcstd_path, export_path, tessellation=20)
logger.info("Assets setup finished without errors")