Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Python node in Xpresso [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    10 Posts 0 Posters 805 Views
    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.
    • H Offline
      Helper
      last edited by

      On 18/12/2014 at 12:55, xxxxxxxx wrote:

      Hi, I hope someone can help. I have a Python node in Xpresso. It has 2 input ports: Count (from a cloner) and Iteration (from an iterator). I am trying to enable and disable 100 Tracer objects based on the count in the cloner. I am using this code in the Python node but nothing is happening. (The list of tracers goes from cord Tracer_01 to cord Tracer_100)

      import c4d
      from c4d import utils
      from c4d import documents
        
        
      mydoc = documents.GetActiveDocument()
      ctl = doc.SearchObject('cord Tracer')
      bc = c4d.BaseContainer()
        
      print ctl
        
      def main() :
          if Count <= Iteration:
              ctl[c4d.ID_BASEOBJECT_GENERATOR_FLAG == 1]
          else:
              ctl[c4d.ID_BASEOBJECT_GENERATOR_FLAG == 0]
        
      c4d.EventAdd()
                  
      if __name__=='__main__':
          main()
      

      Any help would be greatly appreciated. Thanks.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 23/12/2014 at 04:45, xxxxxxxx wrote:

        From the C4D Help:
        There are some limitations with regard to what Python does within a Python Node. Python Nodes are not allowed to directly access the CINEMA  4D project document or objects in the scene via Python. If, for example, you want to ascertain an object's current position within Python you can use XPresso Nodes to do this and pass this information via Ports to Python.
        The Python Node is better suited for processing mathematical calculations and simple program structures, e.g., if-then-else. More complex Python applications should be executed via Python scripts in the Python  Script Manager.
        _
        _
        So I guess that's the problem. You are searching objects from within Python

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 23/12/2014 at 05:11, xxxxxxxx wrote:

          Here's a VERY simple XPresso setup that Enables or Disables Everything in the List.

          Just select the Constant and enable - disable the "Value" button

          http://noseman.org/C4D_dlds/EnableDisableList.zip

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 23/12/2014 at 06:00, xxxxxxxx wrote:

            Thank-you for your reply. I've decided to go with another, sleeker solution.

            PS Cool talk you gave at Siggraph 2013. 🙂

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 23/12/2014 at 07:03, xxxxxxxx wrote:

              Thanks for the compliment 🙂

              Torontonian?
              Where abouts?

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 23/12/2014 at 07:46, xxxxxxxx wrote:

                Hi Thanassis!

                Nice to see you show your nose here at the Plugin Cafe 🙂

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 23/12/2014 at 10:42, xxxxxxxx wrote:

                  Royal York and the Queensway.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 25/12/2014 at 08:50, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    Hi Thanassis!
                    Nice to see you show your nose here at the Plugin Cafe 🙂

                    Hey Yannick! Sticking it wherever I can 🙂

                    Originally posted by xxxxxxxx

                    Royal York and the Queensway.

                    this is uncanny. I'm Park Lawn and Lakeshore... haha 5 minutes away.
                    We are moving to Oakville next month. Let's grab a coffee or beer sometime.
                    email me:
                    noseman [at] noseman [dot] org

                    Merry Christmas and happy new year!

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 05/01/2015 at 04:53, xxxxxxxx wrote:

                      Hi,
                      I'm glad this has already been solved.
                      I was working on this and got held up by Christmas vacation...
                      But as I came up with an example, I thought I post it nevertheless.

                      "Activate Simple Control" is a NULL object with three User Data values: Change Max (integer), Enable (Bool) and Link (a link field).

                      The Python code in "Python Activate Simple" is quite simple:

                      import c4d
                        
                      def main() :
                          if not(doc) or not(Object) :
                              return
                          flagSelect = (Index < Max) or (Max < 0)  # activate all on negative values
                          Object[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = flagSelect
                      
                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        On 05/01/2015 at 05:50, xxxxxxxx wrote:

                        Thanks for taking the time to come up with this elegant solution! I really appreciate it. 👍

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