66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
# -*- 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 utils.sdf_mesh_selector import sdf_mesh_selector
|
|
from remesh import asset_setup
|
|
from export.dae import export_dae
|
|
from export.collision import export_col_stl
|
|
import bpy
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
def freecad_asset_pipeline(fcstd_path,
|
|
mesh_export_path,
|
|
tessellation=10,
|
|
blend_path=None,
|
|
sdf_path=None):
|
|
""" Setup FreeCAD scene to CG asset """
|
|
remove_collections()
|
|
cleanup_orphan_data()
|
|
importer(fcstd_path, tessellation)
|
|
if sdf_path is not None:
|
|
sdf_mesh_selector(sdf_path)
|
|
asset_setup()
|
|
if blend_path is not None:
|
|
bpy.ops.wm.save_as_mainfile(filepath=blend_path)
|
|
export_dae(mesh_export_path)
|
|
export_col_stl(mesh_export_path)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description='Convert and setup FreeCAD solid objects to 3d assets mesh files.')
|
|
parser.add_argument(
|
|
'--fcstd_path', type=str, help='Path to source FreeCAD scene', required=True)
|
|
parser.add_argument(
|
|
'--mesh_export_path', type=str, help='Path for export meshes', required=True)
|
|
parser.add_argument(
|
|
'--tessellation', type=int, help='Tessellation number', default=10, required=False)
|
|
parser.add_argument(
|
|
'--blend_path', type=str, help='Path for export blend assembly file', required=False)
|
|
parser.add_argument(
|
|
'--sdf_path', type=str, help='Path to source SDF assembly file', required=False)
|
|
args = parser.parse_args()
|
|
|
|
freecad_asset_pipeline(args.fcstd_path,
|
|
args.mesh_export_path,
|
|
args.tessellation,
|
|
args.blend_path,
|
|
args.sdf_path)
|
|
|
|
logger.info("Assets setup finished without errors")
|