增肌OCC
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
# from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
# from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -566,20 +566,20 @@ class ResProductMo(models.Model):
|
|||||||
item.model_file = self.transition_glb_file(report_path, model_code)
|
item.model_file = self.transition_glb_file(report_path, model_code)
|
||||||
|
|
||||||
# 将attach的datas内容转为glb文件
|
# 将attach的datas内容转为glb文件
|
||||||
# def transition_glb_file(self, report_path, code):
|
def transition_glb_file(self, report_path, code):
|
||||||
# shapes = read_step_file(report_path)
|
shapes = read_step_file(report_path)
|
||||||
# output_file = os.path.join('/tmp', str(code) + '.stl')
|
output_file = os.path.join('/tmp', str(code) + '.stl')
|
||||||
# write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||||
# # 转化为glb
|
# 转化为glb
|
||||||
# output_glb_file = os.path.join('/tmp', str(code) + '.glb')
|
output_glb_file = os.path.join('/tmp', str(code) + '.glb')
|
||||||
# util_path = get_resource_path('sf_dlm', 'static/util')
|
util_path = get_resource_path('sf_dlm', 'static/util')
|
||||||
# cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||||
# os.system(cmd)
|
os.system(cmd)
|
||||||
# # 转base64
|
# 转base64
|
||||||
# with open(output_glb_file, 'rb') as fileObj:
|
with open(output_glb_file, 'rb') as fileObj:
|
||||||
# image_data = fileObj.read()
|
image_data = fileObj.read()
|
||||||
# base64_data = base64.b64encode(image_data)
|
base64_data = base64.b64encode(image_data)
|
||||||
# return base64_data
|
return base64_data
|
||||||
|
|
||||||
|
|
||||||
class ResMrpBomMo(models.Model):
|
class ResMrpBomMo(models.Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user