Finding duplicate materials - Octane Render
-
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!
-
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 returnsFalse
.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!
-
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!
-
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
-
Hi @r_gigante,
Any luck with this? It's no rush at all for us, just curious if you have an update
Cheers!
Andre
-
Hi @AndreAnjos, no updates so far.
Cheers, R.
-
-
Sooooo, I guess this bug was not adressed still?
Compare returns False even if I compare the same material or copied one. -
Hi @Thodos in which version are you? And would it be possible for you to share a scene?
Thanks in advance,
Cheers,
Maxime. -
Hi, sorry for bringing back up this topic but the Compare() method still gives weird results in 2024.5.1.
- 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.