Solved Detecting TriState

Hello!

I'm using this to detect TriState of an attribute, and it's working fine, but I have some questions...

bool GetNodeTriState( GeListNode* node, const Int32 paramId )
{
	GeData data;
	node->GetParameter( paramId, data, DESCFLAGS_GET_0 );
#if (API_VERSION < 20000)
	auto isTristate = false; // R19 cant detect TriState
#else
	auto isTristate = ( data.GetType() == DA_TRISTATE );
#endif
	return isTristate;
}
  1. Since DA_TRISTATE is new in R20, is there anything else I can do to detect TriState in R19?

  2. When GetParameter() returns a DA_TRISTATE type, how can I get the original data type?
    What about the values?

Hello,

can you share some more code on how exactly are you using your function? Can you provide an example scene?

best wishes,
Sebastian

@s_bach I have an InExclude list, and some parameters that I set for each item. This is managed by a custom class ParameterArrayGroup. I use a dummy attribute for each parameter, and from the object's GetDParameter and SetDParameter, I set the selected item's attribute in a custom data array.

This function detects if the selected items have different values, and set the control as a TriState. This is called from the objet's GetDParameter. The selection vector contains the elements selected on the InExclude list.

	void ParameterArrayGroup::GetDParameter( GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags, const std::vector<bool>& selection )
	{
		if ( parameters_.find( id[0].id ) == parameters_.end() )
			return;

		GeData firstValue;
		auto selectedCount = 0u;
		auto isTriState = false;
		
		for( auto elementIndex = 0u ; elementIndex < selection.size() ; ++elementIndex )
		{
			if( selection[elementIndex] )
			{
				// This will read the specific item attribute from my custom data array
				GetDParameter( node, id, t_data, flags, elementIndex );
				if( selectedCount == 0 )
				{
					firstValue = t_data;
				}
				else if ( !isTriState )
				{
					isTriState = ( firstValue != t_data );
				}
				selectedCount++;
			}
		}
		
		if( isTriState )
		{
#if (API_VERSION >= 20000)
			t_data.SetTristate();
#endif
		}
	}

The result is that when I have multiple items selected, my dummy attribute will display <<Multiple Values>>. When I touch it, ParameterArrayGroup takes care of writing the new value to the array, for each item. Then their value will be the same and TriState is not set anymore. This is working fine.

My question is only if I can set an attribute as TriState on R19.

hello @rsodre ,

just to let you know that I'm waiting for information and I'll come back to you as soon as I've got something to share :)

Cheers
Manuel

MAXON SDK Specialist

MAXON Registered Developer

hello,

I apologies for the delay, I did not forgot you, but it still not have more information about this.

Cheers
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@rsodre said in Detecting TriState:

When GetParameter() returns a DA_TRISTATE type, how can I get the original data type?
What about the values?

i need a bit more information about this part. In my simple example, my data is not returning DA_TRISTATE,
From where main function are you calling GetParameter ?

Cheers
Manuel

MAXON SDK Specialist

MAXON Registered Developer

hello,

can we consider this thread as solved ?

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes Hi Manuel.

The main issue was cleared (R19/R20 differences) we can consider it closed.

Thanks,
Roger

hi,

yes closed is a better word in that case, I still need to add something in the documentation.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer