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

    SetParameter Returns True but Doesn't Update UV Grid Checkbox in C4D

    Cinema 4D SDK
    c++ 2025 windows
    2
    2
    334
    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.
    • S
      shahir zaman
      last edited by

      I'm having this issue where using C4DAtom::SetParameter is returning true as if the updated value was set but it isn't being set, UV_SETTINGS_FILTER_SHOW_GRID is being passed but it isn't actually updating the show UV grid checkbox on the filter tab.
      attempting to make a grid based uv packer.
      help would be greatly appreciated.

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @shahir zaman
        last edited by

        Hi @shahir-zaman ,

        Welcome to the Maxon developers forum and its community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

        • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
        • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
        • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

        It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.

        About your First Question

        Assuming that what you're trying to achieve is to toggle the "UV Grid" option
        d09d5b8d-51a2-4a6a-9618-90b2dbcc6638-image.png
        You effectively have two options:

        1. The easiest one is to execute CallCommand(170776) (you can find the command ID in the Script Log)
        2. The more involved but also more flexible way is to find the UV settings scenehook and go through all its branches (or may be not all of them, depending on what specifically you want to achieve). Please find the C++ and Python code snippets below.

        Cheers,
        Ilia

        C++ commanddata execute function code snippet:

        Bool MyCommandData::Execute(BaseDocument* doc, GeDialog* parentManager)
        {
          const Int32 ID_UV_SETTINGS_HOOK = 1053309;
          
          if (!doc)
            return true;
         
          BaseSceneHook* sceneHook = static_cast<BaseSceneHook*>(doc->FindSceneHook(ID_UV_SETTINGS_HOOK));
          if (!sceneHook)
            return true;
         
          maxon::BufferedBaseArray<BranchInfo, 20> infos;
          sceneHook->GetBranchInfo(infos, GETBRANCHINFO::NONE) iferr_ignore("GetBranchInfo");
         
          for (BranchInfo& info : infos)
          {
            if (info.name != "UVSettingsBranch"_s)
              continue;
         
            GeListNode* viewSettings = info.head->GetFirst();
            while (viewSettings)
            {
              GeData value;
              viewSettings->GetParameter(CreateDescID(UV_SETTINGS_FILTER_SHOW_GRID), value, DESCFLAGS_GET::NONE);
              Bool valueBool = value.GetBool();
         
              value = {!valueBool};
         
              viewSettings->SetParameter(CreateDescID(UV_SETTINGS_FILTER_SHOW_GRID), value, DESCFLAGS_SET::NONE);
         
              viewSettings = viewSettings->GetNext();
            }
          }
         
          EventAdd();
         
          return true;
        }
        

        Python script code snippet (special thanks to @m_adam on this one):

        import c4d
        
        def main() -> None:
            sh = doc.FindSceneHook(1053309)
            for branch in sh.GetBranchInfo():
                if branch["name"] != "UVSettingsBranch":
                    continue
                
                viewSettings = branch["head"].GetFirst()
                while viewSettings:
                    viewSettings[c4d.UV_SETTINGS_FILTER_SHOW_GRID] = not viewSettings[c4d.UV_SETTINGS_FILTER_SHOW_GRID]
                    viewSettings = viewSettings.GetNext()       
                
            c4d.EventAdd()
        
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

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