【问题标题】:Converting scad file format to stl in Python在 Python 中将 scad 文件格式转换为 stl
【发布时间】:2017-11-24 11:41:06
【问题描述】:

有没有办法在 Python 中有效地将 SCAD 文件转换为 STL 格式?我有大约 3000 个文件要转换为 STL。另外,还有一些不同的格式。

我尝试在互联网上搜索一些图书馆,但找不到合适的图书馆(我使用的是 Windows 操作系统)有人知道吗?

【问题讨论】:

  • 你试过solidpy吗?
  • 可以,但是好像不能直接渲染到stl...
  • 不知道,对不起

标签: python stl file-conversion openscad


【解决方案1】:

你可以从命令行运行openscad,见documentation, 并通过python准备每个命令(python3中的示例)

from os import listdir
from subprocess import call

files = listdir('.')
for f in files:
    if f.find(".scad") >= 0:            # get all .scad files in directory
        of = f.replace('.scad', '.stl') # name of the outfile .stl
        cmd = 'call (["openscad",  "-o", "{}",  "{}"])'.format(of, f)   #create openscad command
        exec(cmd)

在 python3.5 及更高版本中,subprocess.call 应替换为 subrocess.run()

【讨论】:

  • 我必须先将openscad添加到路径?
  • en.wikibooks.org/wiki/OpenSCAD_User_Manual/… 下有一些 Windows 注释。但在 Windows 10 上,我无法正常工作。在 linux 上它工作得很好。
  • 所以我应该调用 openscad.exe 而不是 openscad?
  • 我尝试了openscadopenscad.exeopenscad.com 和完整路径相同但没有成功。所以我认为这是另一个问题,如何从 Windows 上的命令行运行 openscad。
  • 哦,好的,等我让它运行时,我会将这个标记为已接受,也许其他人会想出不同的想法 whileist
猜你喜欢
  • 2019-04-18
  • 1970-01-01
  • 2021-08-31
  • 2018-03-06
  • 2019-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-28
相关资源
最近更新 更多