Python Forum
[PyGUI] I can't run Scirpt Blender in background - Blender + Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGUI] I can't run Scirpt Blender in background - Blender + Python
#1
Music 
Hello.
I try create a external graphics user interface, which will do a visualization music (I use Blender as Graphics Engine).

I have problem, because i can’t run script python to blender in command line level (The blender is supposed to run in the background). I have error about bpy.context.area.type:

bpy.context.area.type = "GRAPH_EDITOR";
AttributeError: ‘NoneType’ object has no attribute ‘type’

Please, help me!

CODE Blender script:
import bpy
import sys



for i in range(0,7):
    print(sys.argv[i])
print(type(sys.argv[3])) 
File_save = sys.argv[5]
print(sys.argv[5])
bpy.context.scene.render.filepath = File_save
bpy.context.scene.render.image_settings.file_format = "PNG"                                     
bpy.context.area.type = "GRAPH_EDITOR";
bpy.context.area.type = "TEXT_EDITOR";                                                     

bpy.ops.render.render(animation=False, use_viewport=True)                                                              
bpy.ops.wm.console_toggle()   
CODE GUI:
import tkinter as tk
import os

def Run_Blender():
    FS = '-- D:\Python\TPNG'
    os.system('blender -b -P D:\\Praca_Inżynierska_test\\Blender_testy\\TestBlender.py ' + FS)

WINDOW_SIZE = "450x450"

root = tk.Tk()

root.geometry(WINDOW_SIZE)

myButton = tk.Button(root, text="Run Blender", command=Run_Blender, padx=50, pady=50, fg="blue", bg="yellow")

myButton.grid(row=1, column=0)


root.mainloop()
Larz60+ write Nov-21-2020, 02:57 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Python in python, not quote, tags. Fixed for you this time.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My Background Image Is Not Appearing (Python Tkinter) HailyMary 2 3,974 Mar-14-2023, 06:13 PM
Last Post: deanhystad
  Make Label Text background (default color) transparent using tkinter in python barry76 1 23,473 Nov-28-2019, 10:19 AM
Last Post: Larz60+
  set button background with image of window background gray 3 14,353 Oct-18-2017, 08:22 AM
Last Post: gray

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020