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

    Trouble With Expression Editor

    General Talk
    2
    6
    702
    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.
    • R
      Rurymhn
      last edited by

      So I am in the process of learning how Python and scripting in C4D works.
      Working with this interesting tutorial series, but have falled down at the first hurdle: nothing seems to run from the expression editor.
      I have run scripts successfully from the Script Manager, but nothing so far from the Expression Editor.

      All I have is:
      a cube with a python tag
      The following code:

      import c4d
      import sys
      #Welcome to the world of Python
      
      def main():
          print sys.version
      

      It runs fine in the command line and in the script manager, but not the expression editor looking at the python tag on the cube.

      Any suggestions where I may have gone wrong?

      R21.207 (Build RB303831)

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by Cairyn

        The code actually works fine for me being in a Python Tag on a Cube. When the scene is refreshed, the tag is executed, and the console shows the version line.

        What's happening (or not happening) on your side? Remember that you need to trigger the execution of the tag by doing something in the scene like selecting or forwarding the timeline; the execution context is different from the script manager (where you explicitly trigger the execution by clicking "Execute"). With a tag, the execution is bound to the evaluation of the scene tree.

        1 Reply Last reply Reply Quote 0
        • R
          Rurymhn
          last edited by

          Above is a quick screen grab of me trying to run it.

          1 Reply Last reply Reply Quote 0
          • CairynC
            Cairyn
            last edited by

            You may want to make a viewport visible.

            Apparently, your viewport is somewhere in the background. Under those circumstances, the evaluation of the object tree seems to skip a beat... C4D seems to be thinking "hey, if you don't wanna see my results, I won't bother doing anything" 😉

            I verified this on my system - no viewport, no output!

            (Don't ask me why Maxon is doing that, I don't have access to the inner code...)

            1 Reply Last reply Reply Quote 1
            • CairynC
              Cairyn
              last edited by

              Interesting - not even pressing Execute in the Expression Editor creates an output if the viewport is not visible. Duh, I would have expected that. Maybe it's an actual bug.

              1 Reply Last reply Reply Quote 0
              • R
                Rurymhn
                last edited by

                Bringing the viewport into focus worked... wow, I had a feeling it was something simple like that!

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