简体   繁体   中英

Php: Running a python script using blender from a php project using cmd commands

I need to run in cmd a python script for blender from blender and print the result from a php project, but I don't get the all result.

Here is my code:

$script = "C:\Users\madalina\Desktop\workspace\script.py";
$blander_path = "C:\Program Files\Blender Foundation\Blender";
$output = shell_exec("cd $blander_path && blender -b -P script.py -- $json");
print_r($output);

and here is what I receive:

found bundled python: C:\\Program Files\\Blender Foundation\\Blender\\2.69\\python Blender quit

And here is what i get when i run the same script directly from my cmd 在此处输入图片说明

How can a get the same response when I when the same script from my php project? (I use blender 2.69)

I resolve the problem. I changed the system_exec command with exec, put the json object in quotes.

this is my code now:

$json = str_replace("\"", "\\\"",  json_encode($jsonArray));
$script = "C:\Users\madalina\Desktop\workspace\script.py";
$blander_path = "C:\Program Files\Blender Foundation\Blender";
$output = exec("cd $blander_path && blender -b -P $script -- \"$json\"", $data);
print_r($data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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