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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    search objects

    Scheduled Pinned Locked Moved PYTHON Development
    10 Posts 0 Posters 1.2k 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 15/08/2017 at 07:47, xxxxxxxx wrote:

      hi there...

      is there really no method to search for an object by name returning a list?
      there could be multiple objects with the same name!

      do you have to traverse the complete tree for that???

      best

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

        On 15/08/2017 at 08:06, xxxxxxxx wrote:

        Yes, just iterate over your objects and check for whatever you like to. 🙂
        Non recursive hierarchy iteration is blazingly fast, so don't worry about performance.

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

          On 15/08/2017 at 09:51, xxxxxxxx wrote:

          cant do that 😕

          if i want to search an object name in complex scene,
          it is too slow to walk the complete hierarchy

          if you have to do this all the time it hogs the app

          there really could be better methods to select objects!

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

            On 15/08/2017 at 10:01, xxxxxxxx wrote:

            Well, I don't see any scenario where this would be neccessary though.
            May I ask what you try to achieve?

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

              On 16/08/2017 at 10:37, xxxxxxxx wrote:

              In general mp5gosu is right, the only thing we have is SearchObject(), which can only return one object unfortunately.

              I'd also like to second mp5gosu's question, so we could maybe add ideas.

              If we added a new function, which search criteria should be covered besides names? Types? Existence of certain parameter types or names? Animated parameters? Existence of certain tags? Links to other entities?
              Don't get me wrong. I don't want to turn down your request. If there's a need and some benefit, we will certainly consider the extension of the API.

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

                On 16/08/2017 at 11:32, xxxxxxxx wrote:

                About SearchObject to making it more user friendly we can think about adding a function SearchObjects(who gonna return a list of object)

                Then we can also imagine bunch of options:

                • SearchObjectByType: Check if op match this type
                • SearchObjectByTag: Check if op get this tag type
                • SearchObjectByParameter: Check if op get a certain parameter ? Maybe add addition input for also checking value
                • SearchObjectByParent :Check if op is a child of parent
                • SearchObjectByCustom: Accept a lambda function wich return a bool if op must be selectect or not.

                Then we can think about why maxon should take time for doing this kind of stuff that user can easily down with a correct understanding of the actual SDK?

                • Firstly for new comer. I'ts way more user friendly to simply call SearchObjectByNames and get a list of a object than to build your own list with the need to make a recursive function
                • Optimization, I get no proof about that, but I'm pretty sure most of developers actually doing stupid basic recursive search, while there are more complexes algorithms to optimize it like using multi-threading for exemple.
                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 16/08/2017 at 13:05, xxxxxxxx wrote:

                  Well, I agree with gr4ph0s, in particular on that custom function that accepts lambdas (or even functors, if someone wants that pain)

                  But for "everyday"-use, a filtered list would come in handy.

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

                    On 17/08/2017 at 06:26, xxxxxxxx wrote:

                    I totally agree with you.
                    I didn't thinked about filter (I'm not a big boss about functional programming, but need to improve it !).
                    But should be really come handy even for other task than iterate, combined with the idea I came yesterday it come a very powerful toolset.

                    We would able to write something like this

                    #Constant define inside c4d
                    #FILTER_EGUAL_TO_VALUE = 0
                    #FILTER_GREATER_THAN_VALUE = 1
                      
                    tags = SearchObjectsByTag(c4d.Tphong)
                    tag_to_change_first_step = FilterByParameter(tags, c4d.PHONGTAG_PHONG_ANGLELIMIT, c4d.FILTER_EGUAL_TO_VALUE , True)
                    tag_to_change_second_step = FilterByParameter(tag_to_change_first_step, c4d.PHONGTAG_PHONG_ANGLE, c4d.FILTER_GREATER_THAN_VALUE, 0)
                    
                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 18/08/2017 at 15:43, xxxxxxxx wrote:

                      i think SearchObject() just disrespects the fact that there could be multiple objects with the same name.
                      so SearchObject s () returning a list would be a good idea.

                      additional filter methods etc would nice but its kinda endless and can be done by python anyway

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

                        On 21/08/2017 at 10:51, xxxxxxxx wrote:

                        Thanks for all your input. Much appreciated!
                        I'll take the ideas and forward them to development.

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