Menu parameters identifying as StrMenu

TD2023&2025

This is gonna be pretty random, but I’m working on a tool that deals with Menus but not StrMenus.

I noticed that for example the Text TOP’s Font and Typeface params identify as both String and Menu type even though they appear as a simple Menu:

python >>> op(‘/project1/text1’).par.font.isMenu
True
python >>> op(‘/project1/text1’).par.font.isString
True

Hi,
I see the same bug.

Here is a solution for now:

python >>> op('/project1/text1').par.font.style
'Menu'

Best,
Alex

2 Likes

Yeah, a StrMenu (what you select as a par type in the Comp Editor) is a “style”. isString and isMenu and the other similar type tests just identify certain behaviors of the parameter. It does have string data and it also has a menu to display. To be clear, this is not a bug, just a slightly obtuse meaning of those booleans.

Hi Ivan,
The bug is actually:

python >>> op('/project1/text1').par.font.style
'Menu'
python >>> op('/project1/text1').par.font.isString
True

python >>> op('/project1/text1').par.dispmethod.style
'Menu'
python >>> op('/project1/text1').par.dispmethod.isString
False

Both font and dispmethod are similar menu parameters, but return different isString

Best,
Alex

What the what?!

Okay that is a bug :smiley: will get to the bottom of this

Today I learned a new thing about TD. So here is what is going on:

SOME menus in TD are stored as strings so that you don’t lose your value if for some reason the menu changes between loads. Fonts and devices are the main examples of this. It’s designed to keep the value in the menu even if you move to a system without that font or device.

You can actually assign a string value to those string based menu pars that is not in the menu. So these pars are basically the StrMenu style par without a text entry field (unless you expand it). The gotcha here is that menuIndex is 0 for both the first entry and an unfound entry.

If you want to simulate one of these string-based menu pars with a custom par, the best you can do is make a “StrMenu” style par. The alternative is to make a Menu style par, but that won’t hold the value if for some reason it is removed from the list (e.g. on another system that doesn’t have the font)

The next experimental version of TouchDesigner will sort this out and deal with it more sensibly. For now let’s just never say the word “menuIndex”.

hahah I will never say [redacted] I swear!

Thanks for the insight @Ivan, glad my bug report uncovered such heinous acts!