BlenderToolbox icon indicating copy to clipboard operation
BlenderToolbox copied to clipboard

How to use the python scripts in the folder /demo?

Open Dong-He opened this issue 3 years ago • 2 comments

Dear HTDerekLiu,

I would like to ask how to use the .py scripts in the folder /demo. For example, I run the script demo_isoline.py in Blender scripting module like this. (I have modified some paths on my computer)

image

However, there are errors below. I also tried to run these python scripts in some Python IDE, but it still did not work. Is there any experience on how to run these useful strips? Thanks for your help.

System info: Blender 3.2.2 on Windows 10 x64.

Python: Traceback (most recent call last): File "\demo_isoline.py", line 28, in <module> File "D:\OneDrive - HKUST Connect/2_Tools/BlenderToolbox\BlenderToolBox\subdivision.py", line 18, in subdivision bpy.ops.object.modifier_add(type='SUBSURF') File "C:\Portable Program\blender-3.2.2-windows-x64\3.2\scripts\modules\bpy\ops.py", line 115, in __call__ ret = _op_call(self.idname_py(), None, kw) RuntimeError: Operator bpy.ops.object.modifier_add.poll() Context missing active object

Dong-He avatar Aug 10 '22 13:08 Dong-He

Thanks for the question. I wonder how you executed the script? I tried to reproduce the error on my macOS using Blender 3.2.2, but I failed. What I did was

cd demos/
blender -b -P demo_isoline.py

and I was able to get it rendered.

To further debug your situation, could you try to (1) remove the line about bt.subdivision(...), or (2) run other scripts such as the template.py?

HTDerekLiu avatar Aug 12 '22 17:08 HTDerekLiu

Thanks for your reply. I was trying to load the Python script into Blender software and pressed the run button. Now I typed your commands and it works, Thanks!

Dong-He avatar Aug 13 '22 12:08 Dong-He