Last active
May 21, 2023 18:19
-
-
Save p2or/ebc4d7c98d465de0c1256d2c5f085144 to your computer and use it in GitHub Desktop.
Supress operator output #Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for http://blender.stackexchange.com/questions/56087/check-if-an-operation-can-be-applied-without-runtime-errors | |
import bpy | |
import io | |
from contextlib import redirect_stdout | |
if bpy.ops.mesh.fill_grid.poll(): | |
print("correct context") | |
else: | |
print ("incorrect context") | |
stdout = io.StringIO() | |
with redirect_stdout(stdout): | |
try: | |
bpy.ops.mesh.fill_grid() | |
except: | |
pass | |
stdout.seek(0) | |
output = stdout.read() | |
print("Report was %r" % output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment