问题
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)
回答1:
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);
来源:https://stackoverflow.com/questions/23563809/php-running-a-python-script-using-blender-from-a-php-project-using-cmd-commands