insert shaders with python
-
On 31/01/2018 at 05:05, xxxxxxxx wrote:
Hi guys, I sincerely need your help,
I am trying to manipulate my materials with python...i want to select all my cinema 4d materials, and insert a Filter shader at the top of the color channel texture slot, and then set its lightness to -30%, but without loosing the existing content. Then, in case that the first shader in the texture channel was a bitmap shader, i want to copy the whole content of the slot with my filter on top, and paste it to the bump channel, where i desaturate the new filter shader i have just insert to -100%. Then copy the whole thing again to the reflections channel, change contrast, gamma...
I have menaged to select my cinema 4d materials, change some parameters, and even insert the shader where i want, but i loose everything that was there..._<_img src="http://www.c4dcafe.com/ipb/uploads/monthly_2018_01/image.png.af049136de416a7beb7797e21fabc373.png" height="1000" width="1690" border="0" /_>_
can you please guys help_<_img src="http://https://www.c4dcafe.com/ipb/uploads/monthly_2018_01/image.png.af049136de416a7beb7797e21fabc373.png" border="0" /_>_" />
Another thing...i don' understand why when i try to use the if statement with this formula:
If x == 0:
If s != 0:
it gives me error or do not understand me, but when i use this one:
If x is None:
If x is not None:
it works. What is the difference?....and please have patience with me...I started to learn python 3 days ago, as I fell i love with coding...and forgive me the dumb questions,
thanks to anybody in advance.... -
On 01/02/2018 at 03:51, xxxxxxxx wrote:
Welcome to the Plugin Cafe!
Please do not cross post your questions on multiple forums or at least include a link to your cross posts (cross post on c4dcafe here). This helps everyone to avoid unnecessary work.
Also, it is better to post code as text and not as screenshot because this way it can be easily copy/paste for testing.
I can see in the other thread on c4dcafe you already got an answer with a full script as solution.
Note you don't need to select materials to process these. Also, to not loose the original color shader, it has to be copied and set to the filter texture.Some advices:
As you've done in your script, use ID names and not values directly like in the script that was posted on c4dcafe (c4d.Xfilter instead of 1011128 , c4d.Xbitmap instead of 5833 etc).
Do not put function calls outside of main in the global scope of the script. For instance doc.Start()/EndUndo()/c4d.EventAdd() should be moved inside main().About if statement, the condition depends on the type of the value checked. What's the error message you're getting?
Note statement has to be written if and not If. -
On 01/02/2018 at 08:45, xxxxxxxx wrote:
Thanks for the advice. Why is it better to use ID names? Except for readability
-
On 02/02/2018 at 03:35, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Thanks for the advice. Why is it better to use ID names? Except for readability
Hi,
It's better to use names instead of literal values not only because of readability.
This isn't usual but IDs value might change so using the name ensures the associated number is correct.