Struggling on SetParameter for OLight
-
Hello there!
I'm starting a new TAG plugin development and I would like to affect
OLightparameter, i.e.c4d.LIGHT_COLOR, but myDescIddoes not reach its target.All this is happening in
dataTag.Execute.Here the code, and the
GetParameterreturns onlyNone, which means there is something wrong...# TAG Execute() method def Execute(self, tag, doc, op, bt, priority, flags): self.tagData = tag.GetDataInstance() sim_color = c4d.Vector(0) # For debug purpose, set a black color value if op.GetType() == c4d.Olight: # For debug purpose print( op.GetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_COLOR, 0)), c4d.DESCFLAGS_GET_PARAM_GET ) ) op.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_COLOR, 0)), sim_color, c4d.DESCFLAGS_SET_USERINTERACTION ) return c4d.EXECUTIONRESULT_OKI tried different flags for
SetParameter, but based on @ferdinand explanation on CTrack, it seems thatc4d.DESCFLAGS_SET_USERINTERACTIONis the good one.If someone can light me up on this, that would be awesome.
Cheers,
Christophe -
Little addition after looking for a solution and reading more on
OLight, it seems that the correct data type isc4d.DTYPE_VECTORinstead ofc4d.DTYPE.COLOR. But even with this I can't reach the value.# TAG Execute() method def Execute(self, tag, doc, op, bt, priority, flags): self.tagData = tag.GetDataInstance() sim_color = c4d.Vector(0) # For debug purpose, set a black color value if op.GetType() == c4d.Olight: # For debug purpose print( op.GetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), c4d.DESCFLAGS_GET_PARAM_GET ) ) op.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), sim_color, c4d.DESCFLAGS_SET_USERINTERACTION ) return c4d.EXECUTIONRESULT_OK -
Hi @mocoloco for such a parameter, using the bracket operator will be more easy.
Find bellow the code within a Python Scripting tag, this work as expected.from typing import Optional import c4d doc: c4d.documents.BaseDocument # The document evaluating this tag op: c4d.BaseTag # The Python scripting tag flags: int # c4d.EXECUTIONFLAGS priority: int # c4d.EXECUTIONPRIORITY tp: Optional[c4d.modules.thinkingparticles.TP_MasterSystem] # Particle system thread: Optional[c4d.threading.BaseThread] # The thread executing this tag def main() -> None: obj = op.GetObject() previousLightColor = obj[c4d.LIGHT_COLOR] print(previousLightColor) newLightColor = c4d.Vector(0.0, 1.0, 1.9) obj[c4d.LIGHT_COLOR] = newLightColorBut if you really want to use G/SetParameter you can do it with the code bellow. The issue with your code is that
DESCFLAGS_GET_PARAM_GETmean to be used within the implementation to notify the system that this parameter have been already retrieved so no need to retrieve it again. So if you pass this flag as an input therefor you will have nothing in return.obj = op.GetObject() previousLightColor = obj.GetParameter(c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), c4d.DESCFLAGS_GET_NONE) print(previousLightColor) newLightColor = c4d.Vector(0.0, 0.0, 1.9) obj.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), newLightColor, c4d.DESCFLAGS_SET_NONE )Cheers,
Maxime. -
Hi @m_adam,
Thanks a lot for the flags, it does work as expected now.
Arec4d.DESCFLAGS_GET_NONEandc4d.DESCFLAGS_GET_0similars?Cheers,
Christophe.