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

    Is it possible to build a TreeView from a user database?

    Cinema 4D SDK
    sdk c++
    3
    3
    430
    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.
    • J
      jpheneger
      last edited by

      I have multiple Redshift materials (defined as a database) that I'd like to load into the application and show to the user in a GeDialog.

      I have successfully loaded the database into the application, but it is not clear to me how to traverse the database such that I am able to build up a tree view structure that can be used to navigate the various catetories/assets in the database.

      Using the GetUserPrefsRepository function, I can search for a given category or asset - but only if I know it's ID ahead of time.

      If I know the top level category, is it possible to traverse the repository from that point and build up a TreeView to represent those assets?

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @jpheneger
        last edited by ferdinand

        Hello @jpheneger,

        Thank you for reaching out to us. I would recommend having a look at the Asset API Handbook as it provides examples for most basic to intermediate Asset API related tasks.

        • You can search in the user preferences repository, as it is the union of (allmost) all repositories, but when you want to optimize things, especially when you want to filter out all assets that are not located in your custom database, you should construct a repository for your user data base alone.
        • In Asset API: Asset Metadata I showed traversal by category, but that is usually not what you want to do, as this is potentially ambiguous.
        • If you want to search for all asset types, all asset instances, or all versions of an asset in a repository, you must simply null the respective Id. I would recommend having a look at the three asset search examples in Asset API: Asset Databases.

        If I know the top level category, is it possible to traverse the repository from that point and build up a TreeView to represent those assets?

        Assets are not intrinsically organized in a hierarchy so that one could traverse them naturally in that manner. Instead, the Asset API is simply a database where all items have a category field, and categories are assets themselves and therefore also have such field. If you want a tree data structure for your assets, you will first have to search for all assets in your repo that are of the asset type category which also do not have a parent category, i.e., are "root level" categories. From there on you can then branch out, by seraching for other assets being parented to these assets. The Asset API: Asset Metadata category examples should get you started on how things work. When you are only after a selection window for assets, i.e., an Asset Browser popup, using maxon::AssetManagerInterface::OpenPopup is probably going to be easier than doing things from scratch.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hello @jpheneger,

          without further questions or postings, we will consider this topic as solved by Monday 05/06/2023 and flag it accordingly.

          Thank you for your understanding,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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