On 13/04/2018 at 02:06, xxxxxxxx wrote:
Hi people, as a redshift for c4d user, i'd like to make a little script which would make me win a lot of time. Indeed, i have a lot of objects which contain UVW coordinates to apply textures on them and as redshift use multiple UVW chanels to project them in a different way, i have to manually create different UVW tags to obtain what i want. I explain: let's say i have a cube with a diffuse map using uvw projection, i can also add a noise map for bump (or reflection, etc.) using the cubic projection instead. So i select my material, apply a cubic projection on it and then generate a new uvw tag which name will be "CUBIC". then in the UV chanel of the texture (in RS material) i give each map the good name to project correctly. I hope i am clear ;-)
So, i'd like to do this operation with a script and it seems to me the only way to do that is "python", that i have never used and was sure would never have to. I've tried to copy and paste the code generated by c4d and it works (in a way) because i'm able to generate my new UVW tag but still have to rename it manually (that's what i'd like to avoid). And after long long hours on the web, i'd like real professionals to help me a bit.
So, is it possible? And if it is, how to do that? While searching, i've found "functions" such as SetActive, GetActive, etc. but i don't know how to implement them.
So thank you if you've read this (and understood what i meant) and thank you for your time.
Here is my actual code:
import c4d from c4d import documents, plugins #Welcome to the world of Python def main() : def tool() : return plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL) def object() : return doc.GetActiveObject() def tag() : return doc.GetActiveTag() def renderdata() : return doc.GetActiveRenderData() def prefs(id) : return plugins.FindPlugin(id, c4d.PLUGINTYPE_PREFS) tag()[c4d.TEXTURETAG_PROJECTION]=3 newTag = c4d.CallCommand(12235, 12235) # Générer des coordonnées UVW c4d.EventAdd() if __name__=='__main__': main()
Thanks a lot