Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi @orestiskon,
From what I learnt recently, if you have more than one data to store, you can create a sub container of the base container identified by the pluginID.
I can't remember where I read that... just be careful I'm not an advanced C4D developer
In a class for a BaseTag I use this like that,
self.bcDATAS = c4d.BaseContainer() self.bcDATAS[ myData ] = "A string for example" # Be sure to use a unique ID obtained at https://plugincafe.maxon.net/c4dpluginid_cp myPLUGIN_ID = 0123456789 # Get the Document Settings BaseContainer self.bcDoc = doc.GetDocumentData( c4d.DOCUMENTSETTINGS_DOCUMENT ) self.bcDoc[ myPLUGIN_ID ] = self.bcDATAS # Store plugin container inside the document container # Save the updated Document BC op.SetData( self.bcDoc ) # To retrieve a data print ( op.GetData()[ myPLUGIN_ID ][ myData ] )
Cheers,
Christophe
@orestiskon, self is used because the example is an extract of a class. In my case, those variables are defined in the def __init__ (self):, and belongs to the class object. They are not globals. Have a look there, https://docs.python.org/3/tutorial/classes.html you will understand it with a much better explanation than mine.
def __init__ (self):
If you plan to do not use that inside a class, you can get rid of self of course. Just be careful of doc and op used here below as they are arguments of def Execute(self, tag, doc, op, bt, priority, flags): used in my BaseTag plugin.
self
doc
op
def Execute(self, tag, doc, op, bt, priority, flags):
Knowing this, I assume you can easily transpose this to your purpose as the following example won't work as it is
bcDATAS = c4d.BaseContainer() bcDATAS[ myData ] = "A string for example" # Be sure to use a unique ID obtained at https://plugincafe.maxon.net/c4dpluginid_cp myPLUGIN_ID = 0123456789 # Get the Document Settings BaseContainer bcDoc = doc.GetDocumentData( c4d.DOCUMENTSETTINGS_DOCUMENT ) bcDoc[ myPLUGIN_ID ] = bcDATAS # Store plugin container inside the document container # Save the updated Document BC op.SetData( bcDoc ) # To retrieve a data print ( op.GetData()[ myPLUGIN_ID ][ myData ] )
I noticed by having a look on other .res files that there is a STATICTEXT { JOINEND; } that exists and can be applied on LAYERGROUP as well as STATICTEXT { NEWLINE; } but I didn't got the use of the last one as that does not create the "\r" or "\r\n" it should.
STATICTEXT { JOINEND; }
LAYERGROUP
STATICTEXT { NEWLINE; }
Didn't found any informations in the SDK (C++ nor Python) about JOINEND and JOINENDSCALE... those tags looks like to be undocumented.
JOINEND
JOINENDSCALE
Hi @m_adam,
Thanks a lot for the flags, it does work as expected now. Are c4d.DESCFLAGS_GET_NONE and c4d.DESCFLAGS_GET_0 similars?
c4d.DESCFLAGS_GET_NONE
c4d.DESCFLAGS_GET_0
Cheers, Christophe.
Little addition after looking for a solution and reading more on OLight, it seems that the correct data type is c4d.DTYPE_VECTOR instead of c4d.DTYPE.COLOR. But even with this I can't reach the value.
OLight
c4d.DTYPE_VECTOR
c4d.DTYPE.COLOR
# 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
Hello there!
I'm starting a new TAG plugin development and I would like to affect OLight parameter, i.e. c4d.LIGHT_COLOR, but my DescId does not reach its target.
c4d.LIGHT_COLOR
DescId
All this is happening in dataTag.Execute.
dataTag.Execute
Here the code, and the GetParameter returns only None, which means there is something wrong...
GetParameter
None
# 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_OK
I tried different flags for SetParameter, but based on @ferdinand explanation on CTrack, it seems that c4d.DESCFLAGS_SET_USERINTERACTION is the good one.
SetParameter
c4d.DESCFLAGS_SET_USERINTERACTION
If someone can light me up on this, that would be awesome.
Cheers, Christophe
Hi @ferdinand,
Thanks a lot one more time for all the detailed examples and informations.
I finally opt to a data container of the node, mostly due to the fact that the hooks are volatile and need to be set all the time. I also ran some tests with globals without having encounter issues, but indeed you need to be careful when handling this approach.
Hello @ferdinand,
First of all many thanks for giving a such precise and well documented answers to issues I'm facing, that is tremendous.
Then, you confirmed what I noticed and thought about the redundancy of calling/freeing; and like you said maybe I have to approach the problem differently.
The current plugin I'm working on is use in a really specific case, that way, maybe the approach with the events notification can work. I have to test that based on what you wrote. I was asking this because I want to reset some globals var when the TAG is removed - maybe there is a more elegant way to do, but until now I haven't found one yet.
Have a good day! Cheers,
Hi there,
I'm looking for a reliable method to know when a TAG is deleted. I was hoping that a destructor exists somehow, it it does not work as expected. I tried __del__(self) as well as NodeData.Free(self, node) in my class. Both are called on TAG deletion, but they are also called on any user interaction, which looks really weird.
__del__(self)
NodeData.Free(self, node)
I went through old post, https://plugincafe.maxon.net/topic/7838/10131_message-after-tag-delete?_=1674474478232, which state exactly the same result without any solution.
Is there a way to know when a TAG has been deleted or destroyed from an object without having to watch constantly the whole hierarchy?
Thanks a lot, Cheers,
Oh, I didn't know about the to fix tag. Keeping unsolved was much more for the community I the meantime I setup the resource file as discussed, and indeed, having higher values prior setting them solve the GUI problem / which is a good fix for me.
Good morning @ferdinand,
Thanks a lot for taking time going though this. That's exactly what I noticed last week. Changed are took into account but they are not reflected on the GUI. The only workaround that seems possible at this moment is to set MIN/MAX sliders values beyond the possible values that could be set on UserData. Doing so GUI should behave correctly.
MIN/MAX
Could you please let this thread unsolved for the moment, the time we get a fix on this?
Have a great day, Cheers,
I was quite sure indeed that UNIT PERCENT will work, but I give a try to see. What I do not understand is, when I'm printing all the values existing in desc_X or desc_Y, they looks good, the value is correct, but not took completely into account on the drawing side for CUSTOMGUI REALSLIDER.
UNIT PERCENT
desc_X
desc_Y
CUSTOMGUI REALSLIDER
Like I said, if I remove the CUSTOMGUI REALSLIDER; option in the resource file and using REAL as a standard input field, whatever the UNIT I'm using, everything behaves correctly. MIN/MAX values are correctly assigned even though there is multiple REAL that need to be change. That let me lead like you to a bug linked to CUSTOMGUI REALSLIDER when only using UNIT DEGREE.
CUSTOMGUI REALSLIDER;
UNIT
REAL
UNIT DEGREE
No problem to have a look on this next week. I can deal with that for the moment using PERCENT, as is produce slightly the same result. It is just not really convenient to guess a percentage for an angle, but that's OK.
PERCENT
Many thanks, Cheers,
Thanks a lot for your time on this and sorry for the wrong unit on the first example I submitted with METERS instead of DEGREES - at the sometime it seems that it raised some kind of bug link to this ^^.
METERS
DEGREES
Like you wrote, I did convert the value in Radian for all the Parameters and so, but anyway the problem seems linked to the simultaneous use of UNIT DEGREES; CUSTOMGUI REALSLIDER in the resource file.
UNIT DEGREES; CUSTOMGUI REALSLIDER
I ran a couple of tests and I noticed the following: • When only using REAL without CUSTOMGUI REALSLIDER; in the resource file, the field behaves as it should and limits changes works as expected • When using CUSTOMGUI REALSLIDER; with UNIT METERS; it does work as well as expected • When using UNIT PERCENT; with MIN -100.0; MAX 100.0 and assigning the values by multiplying the slider value by Parameters[--max], printing and assigning the result to a STATICTEXTit displays the right value in degree or rad depending on the final conversion made prior display. • When assigning UNIT DEGREES; with CUSTOMGUI REALSLIDER, I'm getting weird behaviour like said previously and like you noticed.
UNIT METERS;
UNIT PERCENT;
MIN -100.0; MAX 100.0
Parameters[--max]
STATICTEXT
UNIT DEGREES;
I haven't had the time to ran test today with INTERFACE_DATA like you suggested. I will try to do that tomorrow and I will keep you in touch about this.
INTERFACE_DATA