2023-02-01 13:43:23 +00:00
|
|
|
# -*- 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
|
2023-02-08 10:47:54 +03:00
|
|
|
from export.collision import export_col_stl
|
2023-02-01 13:43:23 +00:00
|
|
|
|
|
|
|
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)
|
2023-02-08 10:47:54 +03:00
|
|
|
export_col_stl(export_path)
|
2023-02-01 13:43:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
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")
|