Python Blender 2.7 MacOS控制台错误
我在mac(OS 10.9.2)上使用Blender 2.7,控制台无法正常打开。如果我打开blender.app/Contents/MacOS/blender,我会看到一个新的终端窗口,但它充满了易读和难以辨认的字符,比如“œ˙߹ީ&ÄHÄuuuu PAGEZERO_uuutextÔ。也不会从Blender记录任何打印语句或错误 有人知道发生了什么吗 谢谢 编辑:我也是终端新手,尝试使用/Contents/MacOS目录:p中的“openblender”。如果您在父目录中键入“../blender”,它就可以正常工作Python Blender 2.7 MacOS控制台错误,python,blender,Python,Blender,我在mac(OS 10.9.2)上使用Blender 2.7,控制台无法正常打开。如果我打开blender.app/Contents/MacOS/blender,我会看到一个新的终端窗口,但它充满了易读和难以辨认的字符,比如“œ˙߹ީ&ÄHÄuuuu PAGEZERO_uuutextÔ。也不会从Blender记录任何打印语句或错误 有人知道发生了什么吗 谢谢 编辑:我也是终端新手,尝试使用/Contents/MacOS目录:p中的“openblender”。如果您在父目录中键入“../blen
如果有人能解释一下发生了什么,或者键入“/filename”和“openfilename”之间有什么区别,那就太棒了。Blender需要运行的各种资源与二进制文件位于同一文件夹中,启动Blender时,它会从当前工作目录开始查找它们 在键入命令的终端中,有一个序列(在PATH变量中定义)用于搜索命令,在命令前面加上
/
表示在当前工作目录中运行命令,而不是在路径列表中搜索命令
“打开”命令用于在合适的编辑器中打开可编辑文件,它似乎认为可以使用终端处理该文件,但新终端将在主目录中启动,使blender无法找到其资源。我使用OSX已经有几年了,但它也可能尝试将blender二进制文件作为shell脚本运行。无论哪种方式,open都不会处理可运行的二进制文件,也不是专门设计的
因此不同之处在于,openblender
就像说您想要编辑文件,但是/blender
实际上是从命令行运行应用程序
您还可能发现创建一个applescript相当容易,它告诉终端更改工作目录并启动blender。这可以很容易地保存为一个应用程序,您可以从finder开始。我认为这是(未经测试的)-
如果您在运行脚本时只需要python输出,那么您可能需要尝试—它允许您在blender的python控制台中运行脚本以捕获输出
如果您想获得有关python脚本编写的blender特定帮助,请访问如果此答案与您的问题不完全一致,请向我道歉,但与主题有关: 倾听所有mac用户的声音,这里有一些东西给你: 有了我自己的“恼火”经历,再加上这个想法的帮助,我制作了一个简单的应用程序,目的是用终端打开搅拌机 ---请尝试它,它很容易安装和超级方便--- 是应用程序,如果你想要它,在这里 …是如何使用它:
或者这里是applescript的来源:(目前,有很多有用的评论)
您在几分钟内发布了相同的答案。如果你认为这些问题是相互重复的,你应该把它们标示为这样,而不是对同一问题提出相同的答案。我可以请你复习一下吗?“马蒂金尼特斯:是的,我读过,但是我不认为我会认为这是一个开源的项目”,这是我想分享的一些代码。我为那些不知道如何使用applescript的人开发了一款应用程序。同时,我仍然明白你的观点,下次一定会记住这一点。谢谢
tell application "Terminal"
do script "cd /Applications/blender/blender.app/Contents/MacOS && ./blender"
end tell
set myPath to ((path to current application) as string) --find the path to blenderOpen.app
set myPath to ((characters 1 through ((length of myPath) - 1) of myPath) as string) --rip off the last ":"
set charDelete to (last character of myPath) -- rip off the "blenderOpen.app"
repeat until charDelete = ":" -- rip off the "blenderOpen.app"
set myPath to ((characters 1 through ((length of myPath) - 1) of myPath) as string) -- rip off the "blenderOpen.app"
set charDelete to (last character of myPath) -- rip off the "blenderOpen.app"
end repeat
set myPath to myPath & "MacOS" --find the blender runtime by appending this path
set myPath to quoted form of the POSIX path of myPath -- convert path so terminal understands
(*
why this little if statement down below?
This if statement is here because if a user
opens terminal and runs some command,
then afterwards runs our script,
we want to use a new window so as not
to interfere with the user.
However, if WE open terminal,
than we want to use the window
that terminal just made for us.
*)
if testterminal() then
tell application "Terminal" to do script "cd " & myPath & " && ./blender" -- tell terminal to open new window, and open blender, Voila!!!
else
tell application "Terminal" to tell front window to do script "cd " & myPath & " && ./blender" -- tell terminal to open blender, in the current window, Voila!!!
end if
return myPath
on testterminal()
tell application "System Events" to (name of processes) contains "Terminal"
end testterminal