3
$\begingroup$

I feel like this should be easier to find. Aug '19, I've searched google and stack with no easy answers.

In Blender 2.8:

I'm looking for the code similar to Print("MY_MESSAGE") into the Info window. Obviously it's easy to use Print('...') into the System Console - sys console unrelated to this question.

I'm looking for any sample code I can literally copy paste into my Blender Text Editor window and run with results.

tldr: one-liner print shit to Info window, pls how?!

$\endgroup$
4
  • 1
    $\begingroup$ Here you go: blender.stackexchange.com/questions/717/… $\endgroup$
    – person132
    Aug 27, 2019 at 4:23
  • $\begingroup$ That's like the first thing off google for this question. Not sure if 2.8, or because I don't understand how to correctly use that code, or other reasons, but it does not work for me $\endgroup$ Aug 27, 2019 at 4:31
  • $\begingroup$ Again, for what seems (to me) to be a very basic question - in hack-y script-kiddie code - there seems to be a lack of an easily implemented answer that can be quickly found. I'm looking for a copy-pasta hello world. $\endgroup$ Aug 27, 2019 at 4:35
  • $\begingroup$ Check docs.blender.org/api/blender_python_api_current/… to see how the operator must be called. $\endgroup$
    – eric.m
    Aug 27, 2019 at 7:41

1 Answer 1

3
$\begingroup$

For all the lazy people, who don't like reading the API on how to register and call an operator:

import bpy

class RENDER_OT_test(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "render.custom_test"
    bl_label = "Test"

    def execute(self, context):
        self.report({'INFO'}, 'Printing report to Info window.')
        return {'FINISHED'}

def register():
    bpy.utils.register_class(RENDER_OT_test)

def unregister():
    bpy.utils.unregister_class(RENDER_OT_test)

if __name__ == "__main__":
    register()

Run the script, press F3 to open up the search menu, type Testand press Enter.

No additional link to prevent lazy people from getting even more lazy.

$\endgroup$
6
  • $\begingroup$ Changed my mind: How to script add-on info and warnings? $\endgroup$
    – brockmann
    Aug 27, 2019 at 16:46
  • $\begingroup$ Thank you for this reply! This works for me. The bit that really helped was the F3 -> Test -> Enter, since I am new to Blender. This still seems far more complex than the simple Print(...) statement I hoped for $\endgroup$ Aug 27, 2019 at 23:08
  • 1
    $\begingroup$ Correct, that is by design. The message intentionally only appears when the user is calling something from within the UI (Search Menu, Button, Part of another operator call and whatnot). If that's too complex for your case, use a print("fat flying pigs") @fat_flying_pigs. However, in case you'd like to build an Add-on, using operators is the way to go anyway. Read: How to create a custom UI?. $\endgroup$
    – brockmann
    Aug 28, 2019 at 9:08
  • 1
    $\begingroup$ I knew blender was bad, like "pressing b in file select literally opens a bounding box" bad, but I never knew it was "you literally can't print to the designated console" bad $\endgroup$
    – Andy Ray
    Mar 10, 2020 at 2:16
  • 1
    $\begingroup$ You can print() to the console @AndyRay Question is about how to print into the Info Area... $\endgroup$
    – brockmann
    Mar 10, 2020 at 8:50

Not the answer you're looking for? Browse other questions tagged .