Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to print in the console ?

    Cinema 4D SDK
    2
    3
    603
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KantroninK
      Kantronin
      last edited by

      Hi,

      With a simple script python, we can use 'print' to put a message in the console
      But, with a python plugin this command don't work
      I show my code here:

      def Command(self, id, msg):
      	if id == btnID:
      		print 'Hello World!'				#silently fails (no message in the console)
      		print('Hello World!')				#silently fails (no message in the console)
      		gui.MessageDialog('Hello World!')	#opens a dialog box and displays the message
      

      Thank you for your observations

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by

        Hi,

        you can use the Python 2 keyword print in plugins just fine. Aside from the unusual eight space tab width of your code which could trip Python, you also are missing a return statement. Here is a minimal setup for a CommandData which does print something to the console via a dialog.

        import c4d
        
        class MyDialog(c4d.gui.GeDialog):
            """
            """
            def CreateLayout(self):
                """
                """
                self.AddButton(1000, c4d.BFH_LEFT, 200, 24, "button")
                return True
        
            def Command(self, cid, msg):
                """
                """
                if cid == 1000:
                    print "Hello"
                return True
        
        class MyCommandData(c4d.plugins.CommandData):
            """
            """
            def Execute(self, doc):
                """
                """
                dlg = MyDialog()
                dlg.Open(c4d.DLG_TYPE_MODAL, -1, -1, 200, 200)
                return True
        
        if __name__ == "__main__":
            c4d.plugins.RegisterCommandPlugin(id=10000000, 
                                              str="test", 
                                              info=0, 
                                              icon=c4d.bitmaps.BaseBitmap(), 
                                              help="", 
                                              dat=MyCommandData())
        

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • KantroninK
          Kantronin
          last edited by

          I used the frame of your code to make plugins from scripts that I wrote, and now I can send my results to the console.
          Thanks

          1 Reply Last reply Reply Quote 0
          • First post
            Last post