Volume Object Example
-
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.htmlI'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
-
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 thevolume.framework
in your projectdefinition.txt. You can find the file documented here. This will fix the reference error formaxon::Volume
, although the return type ofVolumeObject::GetVolume
is a bit odd, it returns a pointer to aVolumeInterface
instance and not a reference, i.e., amaxon::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 -
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
-
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. -
Thanks! That worked for me!
Dan