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

    Finding duplicate materials - Octane Render

    Cinema 4D SDK
    python r19
    7
    17
    2.7k
    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.
    • A
      AndreAnjos
      last edited by

      Hi @r_gigante,

      Thank you very much for pointing stuff out! 😃

      first reading your initial question: was hard to understand what you meant with regard to "duplicated" materials and how you were defining the equality among twos. Standing on the solution you presented, basically two materials are identical only and only if the values of all their parameters are equal

      Apologies for this! Should have been more specific with my description.

      second the get_data function expects two arguments, whilst, in your code, only one is given to both calls in the main.

      This has now been updated! Thanks for pointing it out.

      Finally, as pointed out by @PluginStudent, BaseMaterial::Compare() actually does exactly what you're trying to achieve, and any material implementing MaterialData can be checked via this method belonging to the BaseMaterial class to which they inherit from (independently from the rendering engine they belong and assuming they following up with the best practice of storing data in BaseContainers)
      The Compare actually does:

      • compares BaseChannels
      • compares BaseContainers
      • compares Ckeys found in CCurves belonging to CTrack.

      Only when these three checks give all positive results, the two materials are considered identical

      Great! Thank you for your explanation! Did not know if that would be the case since my tests were not coming with the results. So will give it another go!

      Thanks again! 🙂

      1 Reply Last reply Reply Quote 0
      • A
        AndreAnjos
        last edited by AndreAnjos

        Hi @r_gigante

        I must be really stupid here, but can't have the result you are saying with this function.
        A simple test of having 2 supposedly duplicate materials and still returns False.

        import c4d
        
        def main():
        
            mat_lst = doc.GetMaterials()
            result = mat_lst[0].Compare(mat_lst[1])
            print(result)
        
        if __name__ == '__main__':
            main()
        

        I must be missing something very obvious and I can't figure it out. 😆

        Thanks for your help!

        1 Reply Last reply Reply Quote 0
        • A
          AndreAnjos
          last edited by AndreAnjos

          Also as an update!
          I've been talking with a couple of artists here and after a few simple tests using the Delete Duplicate Materials in Cinema R19 and R21, does not work as well.

          Is this a common issue?

          Thanks!

          1 Reply Last reply Reply Quote 0
          • r_giganteR
            r_gigante
            last edited by

            Hi @AndreAnjos, looking at the code it seems I've spotted a bug but it's still under investigation. I'll let you know if that's the case and report back.

            Cheers, R

            A 1 Reply Last reply Reply Quote 0
            • A
              AndreAnjos @r_gigante
              last edited by AndreAnjos

              Hi @r_gigante,

              Any luck with this? It's no rush at all for us, just curious if you have an update 😃

              Cheers!

              Andre

              1 Reply Last reply Reply Quote 0
              • r_giganteR
                r_gigante
                last edited by

                Hi @AndreAnjos, no updates so far.

                Cheers, R.

                1 Reply Last reply Reply Quote 0
                • A
                  AndreAnjos
                  last edited by

                  Hi @r_gigante,

                  Thanks for letting me know!

                  Andre

                  1 Reply Last reply Reply Quote 0
                  • T
                    Thodos
                    last edited by

                    Sooooo, I guess this bug was not adressed still?
                    Compare returns False even if I compare the same material or copied one.

                    1 Reply Last reply Reply Quote 0
                    • M
                      m_adam
                      last edited by

                      Hi @Thodos in which version are you? And would it be possible for you to share a scene?

                      Thanks in advance,
                      Cheers,
                      Maxime.

                      MAXON SDK Specialist

                      Development Blog, MAXON Registered Developer

                      1 Reply Last reply Reply Quote 0
                      • John_DoJ
                        John_Do
                        last edited by John_Do

                        Hi, sorry for bringing back up this topic but the Compare() method still gives weird results in 2024.5.1.

                        Cinema_4D_D5fWj9O4RQ.gif

                        • Comparing a material duplicated with Ctrl-Drag returns sometimes True, sometimes False
                        • Comparing a material against a copy-pasted version (in the same scene) always returns False
                        • Comparing two identical materials both copy-pasted together in one-go in another scene always returns False, even if True was returned in the original scene.

                        Please note that I'm using Corona Materials here but results are the same with the Standard Material.

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