gpt4 book ai didi

python - 如何从 Windows 命令提示符运行 Openscad

转载 作者:行者123 更新时间:2023-11-28 19:07:59 25 4
gpt4 key购买 nike

我试图在 Windows 7 中通过命令提示符运行 OpenScad。但是我无法让它工作。我将以下目录添加到路径

"C:\Program Files\OpenSCAD\"

并尝试运行以下脚本:

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.com", "-o", "{}", "{}"])'.format(of, f) #create openscad command
exec(cmd)

我也用 openscad、openscad.exe、openscad.com 尝试过,到目前为止没有成功。我得到的错误是:

Traceback (most recent call last):
File "C:\Users\Desktop\scad2stl.py", line 9, in <module>
exec(cmd)
File "<string>", line 1, in <module>
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 247, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 955, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The specified file could not be found

有什么建议吗?

最佳答案

我刚看到这个帖子,我已经让它在 windows power shell 上工作,但由于 cmd 而无法让它工作。因此,例如,这不适用于 cmd>

openscad -o render.png --imgsize=2048,2048 assembly.scad

但它确实适用于 power shell(注意 ./在 bigining 中):

./openscad -o render.png --imgsize=2048,2048 assembly.scad

希望对你有帮助。最好的问候

关于python - 如何从 Windows 命令提示符运行 Openscad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44701602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com