Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Detecting TriState

    Cinema 4D SDK
    c++ r19 r20
    3
    9
    927
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rsodreR
      rsodre
      last edited by rsodre

      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?

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

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

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        rsodreR 1 Reply Last reply Reply Quote 0
        • rsodreR
          rsodre @s_bach
          last edited by rsodre

          @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.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by

                @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

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by

                  hello,

                  can we consider this thread as solved ?

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

                  rsodreR 1 Reply Last reply Reply Quote 0
                  • rsodreR
                    rsodre @Manuel
                    last edited by

                    @m_magalhaes Hi Manuel.

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

                    Thanks,
                    Roger

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by

                      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

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post