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).
Hello, I'm trying to set the value of a string with a Static Text interface in my ObjectData plugin.
Here is an example of what I'm trying to achieve. I created it in the UserData by adding Data with a String Data Type and Interface set to String, setting the value, then changing the Interface to Static Text:
In my current Descriptions, I've tried using STRING and STATICTEXT but neither has produced the desired result.
STRING
STATICTEXT
STATICTEXT READOUT_WIDTH { ANIM OFF; }
STRING READOUT_WIDTH { ANIM OFF; }
When using STRING, I try to set the value, but I get the error TypeError:__setitem__ expected float, not str. I don't know how to set it's value then make it a read-only/Static Interface.
TypeError:__setitem__ expected float, not str
op[c4d.READOUT_WIDTH] = str(width)
Can anyone please help me create this type of static text string? Thank you!
hi,
Sorry for the delay of this answer, we simply missed your post.
When using STRING READOUT_WIDTH { ANIM OFF; } it's important that you initialize the parameter in your Init function. Otherwise uninitialized type will be a int. At some point, the code is comparing the old value type with the new value. That's why it's waiting for a Int while you provide a Str. (feel like a bug to me)
Init
int
I don't see the problem using STATICTEXT or STRING. It does create the expected fields. The StaticText can't be Animated anyway, i would remove the ANIM OFF
ANIM OFF
STATICTEXT PYPREFERENCE_STATICTEXT {} STRING PYPREFERENCE_STRING { }
about the border around the static text you can declare the field like this in your ressource file:
STATICTEXT PYPREFERENCE_STATICTEXT_BORDER {BORDER;}
Cheers, Manuel
I sort of have a solution, but would love feedback on the right way to do this:
I'm setting the string with this code:
node.SetParameter(c4d.READOUT_WIDTH, str(width), c4d.DESCFLAGS_SET_0)
Then in NodeData.GetDDescription, I'm setting the Description Parameter's DESC_CUSTOMGUI to DTYPE_STATICTEXT.
DESC_CUSTOMGUI
DTYPE_STATICTEXT
width = description.GetParameterI(c4d.READOUT_WIDTH) if width : width[c4d.DESC_CUSTOMGUI] = c4d.DTYPE_STATICTEXT
The difference between this and the UserData version is the UserData version has a box around the String's value while the above does not. Any feedback would be fantastic. Thank you!