Normally, I would use "blender -P script.py" to run a python script. In this case, a new blender process is started to execute the script. What I am trying to do now is to run a script using a blender process that is already running, instead of starting a new one.
通常,我会使用“blender -P script.py”来运行python脚本。在这种情况下,启动新的blender进程来执行脚本。我现在要做的是使用已经运行的blender进程运行脚本,而不是启动一个新脚本。
I have not seen any source on this issue so far, which makes me concern about the actual feasibility of this approach.
到目前为止,我还没有看到任何关于这个问题的消息来源,这让我对这种方法的实际可行性感到担忧。
Any help would be appreciated.
任何帮助,将不胜感激。
2 个解决方案
#1
1
Blender isn't designed to be started from the cli and to then keep receiving more commands from the cli as it is running. It does however include a text editor that can open text files and run the text block as a python script, it also includes a python console that can be used to interactively type in commands while blender is running. You may also find this addon useful as it lets you to run a text block in the python console, this leaves you with an interactive session that contains the variables as they exist at the end of the scripts execution.
Blender不是设计为从cli启动,然后在运行时继续从cli接收更多命令。但它包含一个文本编辑器,可以打开文本文件并将文本块作为python脚本运行,它还包括一个python控制台,可用于在blender运行时以交互方式键入命令。您可能还会发现这个插件非常有用,因为它允许您在python控制台中运行文本块,这将为您提供一个交互式会话,其中包含脚本执行结束时存在的变量。
There is a cli option to run blender as a python console blender --python-console
- the gui does not get updated while this console is running, so you could open and exec several scripts and then when you exit the console, blender will update it's gui and allow interactive use, or if you start in background mode -b
then it will quit when you exit the console.
有一个cli选项来运行blender作为python控制台blender --python-console - 当这个控制台运行时gui没有得到更新,所以你可以打开并执行几个脚本然后当你退出控制台时,blender会更新它是gui并允许交互式使用,或者如果你以后台模式-b启动,那么它将在你退出控制台时退出。
#2
1
My solution was to launch Blender via console with a python script (blender --python script.py) that contains a while loop and creates a server socket to receive requests to process some specific code. The loop will prevent blender from opening the GUI, and the socket will handle the multiple requests inside the same blender process.
我的解决方案是通过控制台启动Blender,其中包含一个包含while循环的python脚本(blender --python script.py),并创建一个服务器套接字来接收处理某些特定代码的请求。循环将阻止blender打开GUI,并且套接字将在同一个blender进程内处理多个请求。
#1
1
Blender isn't designed to be started from the cli and to then keep receiving more commands from the cli as it is running. It does however include a text editor that can open text files and run the text block as a python script, it also includes a python console that can be used to interactively type in commands while blender is running. You may also find this addon useful as it lets you to run a text block in the python console, this leaves you with an interactive session that contains the variables as they exist at the end of the scripts execution.
Blender不是设计为从cli启动,然后在运行时继续从cli接收更多命令。但它包含一个文本编辑器,可以打开文本文件并将文本块作为python脚本运行,它还包括一个python控制台,可用于在blender运行时以交互方式键入命令。您可能还会发现这个插件非常有用,因为它允许您在python控制台中运行文本块,这将为您提供一个交互式会话,其中包含脚本执行结束时存在的变量。
There is a cli option to run blender as a python console blender --python-console
- the gui does not get updated while this console is running, so you could open and exec several scripts and then when you exit the console, blender will update it's gui and allow interactive use, or if you start in background mode -b
then it will quit when you exit the console.
有一个cli选项来运行blender作为python控制台blender --python-console - 当这个控制台运行时gui没有得到更新,所以你可以打开并执行几个脚本然后当你退出控制台时,blender会更新它是gui并允许交互式使用,或者如果你以后台模式-b启动,那么它将在你退出控制台时退出。
#2
1
My solution was to launch Blender via console with a python script (blender --python script.py) that contains a while loop and creates a server socket to receive requests to process some specific code. The loop will prevent blender from opening the GUI, and the socket will handle the multiple requests inside the same blender process.
我的解决方案是通过控制台启动Blender,其中包含一个包含while循环的python脚本(blender --python script.py),并创建一个服务器套接字来接收处理某些特定代码的请求。循环将阻止blender打开GUI,并且套接字将在同一个blender进程内处理多个请求。