Calling Blender from PHP/Python and Blender doesn't open

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

The code below is a simplified version of the process I am creating. On my local machine this process works fine, but on my companies server, it does not work. It will time out. One thing to note, when I look in the server task manager (Windows), Blender will start as a background process, but not active. In my regular process, Blender will render a file , but that does not happen in my full process. After the call to Blender, it never finishes. Below is a simplified version of my process.

Form to enter information

doctype html>
<body>

<form action="dosomething.php" method="post" enctype="multipart/form-data">
    <input type="text" name="time" placeholder="some number" id="time">
    <input type="submit" name="submit" value="Submit">
form>

body>
html>

PHP to take values and pass to python

doctype html>
<body>

php

$outputDir = "output/";
$outputDirFull = 'C:/xampp/htdocs/test/output/';
$errorDir = "error/";

//move spaces to all spaces in blender path; will be removed in CallBlender.py; necessary to pass to python
$blenderWithSpaces = 'C:/Program Files/Blender Foundation/Blender/blender.exe';
$blender = str_replace(" ","#",$blenderWithSpaces);
$blenderFile = 'blenderfile/test.blend';

$blenderScript = 'pythonfile/testscript.py';

//Specify python and CallBlender.py
$python = "C:/Users/Render/Anaconda3/python.exe";
$pyscript = "pythonfile/CallBlender.py";


$time = $_POST["time"];

//creating the command, and passing time and efficiency; spaces are kept in command because the quotes
$command ="$python $pyscript $time $blender $blenderFile $blenderScript $outputDirFull 2>&1";

//executing the command to call processing python program
exec($command, $output, $return_var);
?>
body>
html>

Python to call blender

import os
import sys
import subprocess

testfile = 'output/output.txt'

#read in values from PHP
time = sys.argv[1]
blender = sys.argv[2]
blenderFile = sys.argv[3]
blenderScript = sys.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community