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

    Volume Object Example

    Cinema 4D SDK
    2023 c++
    3
    5
    745
    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.
    • D
      d_schmidt
      last edited by

      Hello! I was trying to get the Volume Object example working that's in the SDK here:
      https://developers.maxon.net/docs/cpp/2023_2/page_manual_volumeobject.html

      I'm having trouble having it successfully compile though.

      The two headers I'm including:
      #include "lib_volumeobject.h"
      #include "lib_volumebuilder.h"

          BaseObject* object = static_cast<BaseObject*>(node->GetDown());
          
          // create VolumeObject
          // This example checks if the given object is a volume builder.
          // If so, it accesses the cache to get the VolumeObject.
         
          if (object == nullptr)
              return true;
          // check if VolumeBuilder
          if (object->IsInstanceOf(Ovolumebuilder) == false)
              return true;
         
          VolumeBuilder* const volumeBuilder = static_cast<VolumeBuilder*>(object);
         
          // get cache
          BaseObject* const cache = volumeBuilder->GetCache(nullptr);
          if (cache == nullptr)
              return true;
         
          // check for volume object
          if (cache->IsInstanceOf(Ovolume))
          {
            const VolumeObject* const volumeObject = static_cast<VolumeObject*>(cache);
         
            const maxon::VolumeInterface* volInterface =   volumeObject->GetVolume();
          
           const maxon::String  gridname2 = volInterface->GetGridName();
              //Error:: Member access into incomplete type 'const maxon::VolumeInterface'
           
              
              const maxon::Volume       volume = volumeObject->GetVolume();
           // Error::   No type named 'Volume' in namespace 'maxon'
              
              
            const maxon::String gridName = volume.GetGridName();
            DiagnosticOutput("Grid Name: @", gridName);
          }
      

      I'm having problems with these two bits:

      const maxon::VolumeInterface* volInterface =   volumeObject->GetVolume();
      
      const maxon::String  gridname2 = volInterface->GetGridName();
      //Error:: Member access into incomplete type 'const maxon::VolumeInterface'
               
                  
      const maxon::Volume       volume = volumeObject->GetVolume();
      // Error::   No type named 'Volume' in namespace 'maxon'
      

      Is there some sort of header that I need to include or is the example out of date?

      Thanks for any help!

      Dan

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

        Hello @d_schmidt,

        //Error:: Member access into incomplete type 'const maxon::VolumeInterface'

        Means you are missing the interface declaration, you must include "maxon/volume.h" and be sure to have the volume.framework in your projectdefinition.txt. You can find the file documented here. This will fix the reference error for maxon::Volume, although the return type of VolumeObject::GetVolume is a bit odd, it returns a pointer to a VolumeInterface instance and not a reference, i.e., a maxon::Volume. I asked the responsible developer, and he told me it is for some optimization reason. However the type that you should use is really a maxon::Volume like so

        #include "lib_volumeobject.h"
        #include "lib_volumebuilder.h"
        #include "maxon/volume.h"
        
        BaseObject* object = doc->GetFirstObject();
        
        VolumeBuilder* const volumeBuilder = static_cast<VolumeBuilder*>(object);
        
        // get cache
        BaseObject* const cache = volumeBuilder->GetCache(nullptr);
        if (cache == nullptr)
        	return false;
        
        // check for volume object
        if (cache->IsInstanceOf(Ovolume))
        {
        	const VolumeObject* const volumeObject = static_cast<VolumeObject*>(cache);
        	const maxon::Volume       volume = volumeObject->GetVolume();
        	const maxon::String       gridName = volume.GetGridName();
        	DiagnosticOutput("Grid Name: @", gridName);
        }
        

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • D
          d_schmidt
          last edited by

          Hi Ferdinand,

          Thanks for the reply!

          When you said to add volume.framework, did you mean like this? I'm working from the SDK examples for this test.

          // Supported platforms - can be [Win64;OSX]
          Platform=Win64;OSX
          
          // Type of project - can be [Lib;DLL;App]
          Type=DLL
          
          // API dependencies
          APIS=\
          asset.framework;\
          cinema.framework;\
          cinema_hybrid.framework;\
          crypt.framework;\
          core.framework;\
          command.framework;\
          image.framework;\
          math.framework;\
          mesh_misc.framework;\
          volume.framework;\
          python.framework;
          
          // C4D component
          C4D=true
          
          stylecheck.level=0 // must be set after c4d=true
          stylecheck.enum-registration=false
          stylecheck.enum-class=false
          
          // Custom ID
          ModuleId=net.maxonexample.cinema4dsdk
          
          

          It doesn't seem to me working for me here, with maxon/volume.h not being found. I've tried a few others things but none of them seem to be working. Do I need to add the framework somewhere else as well?

          Thanks again,

          Dan

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

            Hi @d_schmidt correct this is the file, did you regenerate the project with the project tool?
            Each time you modify the projectdefinition.txt you should regenerate the project you describe in this file.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • D
              d_schmidt
              last edited by

              Thanks! That worked for me!

              Dan

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