Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Change LONG_CYCLE selected Item.

    Cinema 4D SDK
    c++ r20 windows
    8
    11
    1.9k
    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.
    • ManuelM
      Manuel
      last edited by

      hello,

      You can set the default value you want in your Init function.
      In any case, the Cycle will show the value corresponding to the value of the parameter.

      #define MY_CYCLE_ID 1000
      
      class DefaultCycleValue : public ObjectData
      {
      	INSTANCEOF(DefaultCycleValue, ObjectData)
      public:
      
      	virtual Bool Init(GeListNode *node)
      	{
      		// set the parameter the value we want, the Custom GUI will show the corresponding line in the box.
      		node->SetParameter(DescID(MY_CYCLE_ID), GeData(1), DESCFLAGS_SET::NONE);
      		return true;
      	};
      
      	virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags) override
      	{
      	
      		if (!description->LoadDescription(node->GetType()))
      			return false;
      
      		const DescID* singleid = description->GetSingleDescID();
      		const DescID cid = DescLevel(MY_CYCLE_ID, DTYPE_LONG, 0);
      
      		if (!singleid || cid.IsPartOf(*singleid, nullptr))
      		{
      
      			// add the parameter as long
      			BaseContainer bc = GetCustomDataTypeDefault(DTYPE_LONG);
      
      			// set the custom GUI to a cycle.
      			bc.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_CYCLE);
      			bc.SetString(DESC_NAME, "Long Cycle"_s);
      			bc.SetInt32(DESC_SCALEH, 1);
      
      			// cycle elements
      			BaseContainer items;
      			items.SetString(0, String("Item 0"));
      			items.SetString(1, String("Item 1"));
      			items.SetString(2, String("Item 2"));
      
      			bc.SetContainer(DESC_CYCLE, items);
      
      			// icons
      			BaseContainer icons;
      			icons.SetInt32(0, IDM_COPY);
      			icons.SetInt32(1, IDM_CUT);
      			icons.SetInt32(2, IDM_DELETE);
      
      			bc.SetContainer(DESC_CYCLEICONS, icons);
      
      
      			description->SetParameter(cid, bc, ID_OBJECTPROPERTIES);
      		}
      
      		flags |= DESCFLAGS_DESC::LOADED;
      
      		return SUPER::GetDDescription(node, description, flags);
      	};
      
      
      	static NodeData *Alloc() { return NewObjClear(DefaultCycleValue); }
      };
      

      Cheers
      Manuel

      MAXON SDK Specialist

      MAXON Registered Developer

      1 Reply Last reply Reply Quote 2
      • O
        Ogers
        last edited by

        Thank you @m_magalhaes

        1 Reply Last reply Reply Quote 0
        • J
          JeffreyZimmerman @Ogers
          last edited by JeffreyZimmerman

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • H
            HectorSmallwood @Ogers
            last edited by Manuel

            Everything goes fine until the point I want to change the selected item. Assume that I have the following code, the Item with id 0 will be selected by default. Is there any way that I can change this? Like after a specific action the Item 1 will be selected?
            event to determine when the selected item in the ListBox is changed.

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

              hello @HectorSmallwood

              @HectorSmallwood said in Change LONG_CYCLE selected Item.:

              Assume that I have the following code, the Item with id 0 will be selected by default. Is there any way that I can change this? Like after a specific action the Item 1 will be selected?

              That's exactly what the code is doing in the Init() function using SetParameter(). You change the value of the parameter, the UI show the item with that value in the list. So by default the parameter value is 1 so the UI show the item with the value 1 "Item 1"

              If you want to change the item somewhere else, same thing just change the value of the parameter, the ui will follow.

              node->SetParameter(DescID(MY_CYCLE_ID), GeData(1), DESCFLAGS_SET::NONE);
              

              I'am adding an answer here as it is a related. But for your second question if the answer doesn't fit your need, please open a new thread and post your question in a new thread. That will help us to keep things organized.

              @HectorSmallwood said in Change LONG_CYCLE selected Item.:

              event to determine when the selected item in the ListBox is changed.

              If i understand the question, you have to check for MSG_DESCRIPTION_CHECKUPDATE message type in the Message() function as follow.

              virtual Bool Message(GeListNode* node, Int32 type, void* data) override
              	{
              		switch (type)
              		{
              			case MSG_DESCRIPTION_CHECKUPDATE :
              			{
              				DescriptionCheckUpdate* dcu = static_cast<DescriptionCheckUpdate*>(data);
              				if (dcu == nullptr)
              					return true;
              
              				maxon::Int32 id = (*(dcu->descid))[0].id;
              				if (id == MY_CYCLE_ID)
              				{
              					DiagnosticOutput("Cycle have been changed");
              						// ... do Something
              				}
              				break;
              			}
              		}
              		return true;
              	};
              

              Cheers
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              W 1 Reply Last reply Reply Quote 0
              • W
                williamgutierrez @Manuel
                last edited by williamgutierrez

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • CairynC
                  Cairyn
                  last edited by

                  Am I the only one who sees three posts in this thread defaced by insertions of spam into a valid post?

                  1 Reply Last reply Reply Quote 2
                  • M
                    mogh
                    last edited by

                    yesterday I saw 2 small triangles which i didn't unfold .... today they are gone... addblocker at work ?

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

                      hi,

                      thanks for pointing those spam. I cleaned them

                      Cheers,
                      Manuel

                      MAXON SDK Specialist

                      MAXON Registered Developer

                      1 Reply Last reply Reply Quote 0
                      • W
                        walthenry
                        last edited by

                        Thanks for guiding

                        Regards,
                        Folexin

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