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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Create custom menu category for nodes?

    Cinema 4D SDK
    s24 c++
    2
    2
    473
    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.
    • O
      Ogers
      last edited by

      Hello,
      Is it possible to create a custom menu category for nodes or should we use the ones that already exist?
      I could not find any way or example of how I can achieve this.

      Thank you.

      d8da1d87-ed83-4380-b9b7-9b0413cc7d30-image.png

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

        Hi,

        Categories are also assets. You can use the CategoryAssetInterface to create a category asset.
        and you can "parent" this category to another category using SetAssetCategory.

        maxon::Result<maxon::AssetDescription> CreateCategoryAsset(
          const maxon::AssetRepositoryRef& repository, const maxon::String& name, 
          const maxon::Id& category)
        {
          iferr_scope;
        
          if (name.IsEmpty())
            return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION, "Invalid category name."_s);
        
          // Create and store a new category asset.
          maxon::CategoryAsset categoryAsset = maxon::CategoryAssetInterface::Create() iferr_return;
          maxon::Id	categoryId = maxon::AssetInterface::MakeUuid("category", false) iferr_return;
          maxon::AssetDescription assetDescription = repository.StoreAsset(
            categoryId, categoryAsset) iferr_return;
        
          // Set the category name.
          maxon::LanguageRef language = maxon::Resource::GetCurrentLanguage();
          assetDescription.StoreMetaString(maxon::OBJECT::BASE::NAME, name, language) iferr_return;
        
          // Set the category of the asset when the category is not the empty id.
          if (!category.IsEmpty())
          {
            maxon::CategoryAssetInterface::SetAssetCategory(assetDescription, category) iferr_return;
          }
        
          ApplicationOutput("Created category asset with the id: '@'", assetDescription.GetId());
        
          return assetDescription;
        }
        
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

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