On 18/04/2018 at 22:06, xxxxxxxx wrote:
Thanks again Riccardo!
This has helped me quite a bit but I'm still running into some issues.
I have a MessageData plugin responding to EVMSG_CHANGE, and I've used the script editor to prototype the action I need to occur on the Redshift material:
import c4d
from c4d import documents, utils
def main() :
doc = documents.GetActiveDocument()
mat = doc.GetActiveMaterial()
if mat:
node = mat[c4d.REDSHIFT_GRAPH_NODES]
while node:
if node[c4d.GV_REDSHIFT_SHADER_META_CLASSNAME] == 'Material':
mat_bc = node.GetOperatorContainer()
desc = node.GetDescription(c4d.DESCFLAGS_DESC_0)
for bc, paramid, groupid in desc:
if paramid[0].dtype == c4d.DTYPE_COLOR and paramid[0].creator == 0:
color = mat_bc[paramid[0].id]
mat_bc[paramid[0].id] = utils.TransformColor(color, c4d.COLORSPACETRANSFORMATION_LINEAR_TO_SRGB)
node.SetOperatorContainer(mat_bc)
c4d.EventAdd()
node = node.GetNext()
if __name__=='__main__':
main()
However, I can't figure out an elegant way to make sure that I only perform the above action to the proper Redshift material graph when a new material preset is selected for that material. Initially the problem was that whenever the EVMSG_CHANGE message was being received it would update the colors on the active material, which obviously happens way too frequently. I changed my MessageData plugin to keep track of the previous material preset but that goes out of sync if you switch from material to material.
It seems that I need a way to determine whether the EVMSG_CHANGE was triggered by a specific attribute being modified. Is that possible? I have to admit that I'm still struggling to understand the details of Descriptions, DescIDs and DescLevels but I'm glad to finally be tackling this stuff :)