framework/cg/freecad/utils/freecad_cmd.py

56 lines
1.6 KiB
Python

# coding: utf-8
#!/usr/bin/env python
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import subprocess
import json
def freecad_proc(*args, **kwargs):
command = [
args[0],
args[1],
# general property
kwargs['filename'],
kwargs['tesselation_method'],
kwargs['linear_deflection'],
kwargs['angular_deflection'],
kwargs['fem_size'],
kwargs['skiphidden'],
kwargs['nonsolid_property'],
]
proc = subprocess.run(command,
check=True,
stdout=subprocess.PIPE,
encoding='utf-8')
return json.loads(proc.stdout.split('FreeCAD ')[0])
kwargs = {}
kwargs['filename'] = '/<path to .FCStd>'
kwargs['tesselation_method'] = 'Standard'
kwargs['linear_deflection'] = '0.1'
kwargs['angular_deflection'] = '30.0'
kwargs['fem_size'] = '10.0'
kwargs['skiphidden'] = 'True'
kwargs['nonsolid_property'] = 'Robossembler_NonSolid'
js_data = freecad_proc(
'freecadcmd',
'/<path to>/cg/freecad/utils/export_freecad_scene.py',
**kwargs)
print(js_data)