简体   繁体   English

在Linux主机上运行Blender脚本

[英]Running a blender script on linux hosting

I am currently working on a web app which spits out a .stl file in blender. 我目前正在使用网络应用程序,该应用程序会在Blender中吐出.stl文件。 I have used php and I am calling the script in php using exec(). 我已经使用过php,并且正在使用exec()在php中调用脚本。 Please look at the code below. 请查看下面的代码。 I found the code from Php: Running a python script using blender from a php project using cmd commands 我从Php中找到了代码:使用cmd命令从php项目中的Blender运行python脚本

$script = "C:\\xampp\\htdocs\\test\\test.py";
$blender_path = "C:\Program Files\Blender Foundation\Blender";

$output = exec("cd $blender_path && blender -b -P $script", $data);
echo "<pre>";
print_r($data);
echo "</pre>";

And all works well locally. 所有在本地都可以正常工作。 I uploaded the content to my site(Linux hosting), Uploaded Blender(Linux - https://www.blender.org/download/ ) changed the paths and nothing happens. 我将内容上传到我的网站(Linux托管),上传了Blender(Linux- https://www.blender.org/download/ )更改了路径,但没有任何反应。 It doesn't even output any errors. 它甚至不输出任何错误。 Is there a separate command line code for linux? Linux是否有单独的命令行代码? I am not used to using Linux and I have been struggling with this for the past 3 days. 我不习惯使用Linux,并且在过去三天里一直在为此苦苦挣扎。

Any help is appreciated. 任何帮助表示赞赏。

I can think of two possibilities. 我可以想到两种可能性。 The first is the path names, on linux there is no drive letters a path should be something like /home/aniket/tests/blendtest 第一个是路径名,在Linux上没有驱动器号,路径应类似于/home/aniket/tests/blendtest

The second relates to running a program, I would expect an error but you may have to look into log files to find it or increase the verbosity of php. 第二个问题与运行程序有关,我可能会遇到错误,但是您可能必须查看日志文件才能找到它或增加php的详细程度。 The first point is that a file needs permissions set to be executable, this would involve chmod +x blender or maybe using your ftp software to set this, it is often represented as X within a permissions string like RWXRWXRWX . 第一点是文件需要将权限设置为可执行文件,这将涉及chmod +x blender或可能使用ftp软件进行设置,它通常在权限字符串(如RWXRWXRWX表示为X The second point is the way commands are found on a *nix system, there is a PATH environment variable that lists directories to look for a command, the current directory is not in that list by default and I wouldn't expect a hosting company to add it. 第二点是在* nix系统上找到命令的方式,有一个PATH环境变量列出了要查找命令的目录,默认情况下当前目录不在该列表中,而且我不希望托管公司这样做添加它。

$script = "/home/aniket/test1/test.py";
$blendexe = "/home/aniket/blender2.76/blender";

$output = exec("$blendexe -b -P $script", $data);
echo "<pre>";
print_r($data);
echo "</pre>";

On *nix systems ./ represents the current directory, so you may also have luck using 在* nix系统上,. ./代表当前目录,因此您可能还可以使用

$output = exec("cd $blender_path && ./blender -b -P $script", $data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM