dongchangxi 11 months ago
parent
commit
3f48cb12f0
  1. 25
      apps/auto_convert3d.py

25
apps/auto_convert3d.py

@ -176,6 +176,22 @@ def team_check(r):
glb_filename = f'{pid}.glb' glb_filename = f'{pid}.glb'
print('开始转换obj文件为glb文件...') print('开始转换obj文件为glb文件...')
os.system(f'gltfpack -c -i {os.path.join(workdir, "print", pid, obj_filename)} -o {os.path.join(workdir, "print", pid, glb_filename)} -vt 16 -vc 16') os.system(f'gltfpack -c -i {os.path.join(workdir, "print", pid, obj_filename)} -o {os.path.join(workdir, "print", pid, glb_filename)} -vt 16 -vc 16')
#处理封面图
#执行获取obj缩略图
print("执行获取obj全身缩略图脚本")
os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print/{pid} -o D://print/{pid}')
#判断文件是否存在,存在则上传到oss, 更新数据库内容
if os.path.exists(f'D://print/{pid}/{pid}_pic.png'):
#获取拍照订单的信息,从中得到拍照订单的信息
uuid = get_p3d_info(str(pid))
if uuid != 0:
print("uuid",uuid)
config.oss_bucket_3d_view.put_object_from_file(f'{uuid}/3d_view.png', f'D://print/{pid}/{pid}_pic.png')
#os.system(f'FBX2glTF -i {os.path.join(workdir, "print", pid, obj_filename)} -o {os.path.join(workdir, "print", pid, glb_filename)}') #os.system(f'FBX2glTF -i {os.path.join(workdir, "print", pid, obj_filename)} -o {os.path.join(workdir, "print", pid, glb_filename)}')
#如果压缩后的glb文件小于2M,文件贴图异常,需要重新生成,直到成功 #如果压缩后的glb文件小于2M,文件贴图异常,需要重新生成,直到成功
# while os.path.getsize(os.path.join(workdir, "print", pid, glb_filename)) < 2 * 1024 * 1024: # while os.path.getsize(os.path.join(workdir, "print", pid, glb_filename)) < 2 * 1024 * 1024:
@ -198,6 +214,15 @@ def team_check(r):
shutil.rmtree(os.path.join(workdir, 'print', pid), ignore_errors=True) shutil.rmtree(os.path.join(workdir, 'print', pid), ignore_errors=True)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end') print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end')
def get_p3d_info(pid):
url = "https://mp.api.suwa3d.com/api/customerP3dLog/info?id="+pid
res = requests.get(url)
res = res.json()
if res["code"] == 1000:
return res["data"]["guid"]
else:
return 0
def platform_check(r): def platform_check(r):
try: try:
if r.llen('model:modelRepairGLBQueue') == 0: if r.llen('model:modelRepairGLBQueue') == 0:

Loading…
Cancel
Save