How to use GetAllNimbusRefs in 2023
-
Hi,
I am trying to call the following code in 2023. From this page.// Print all the NodeSpace ID from the selected material. In practice we should // test if mat is a nullptr before proceeding. BaseMaterial* mat = doc->GetActiveMaterial(); // The error handling needs to have an error context defined with either iferr_scope or iffer_handler. const maxon::HashMap<maxon::Id, maxon::NimbusForwardRef> hashNimbusRefs = mat->GetAllNimbusRefs() iferr_return; for (const auto& e : hashNimbusRefs) { const maxon::Id& key = e.GetKey(); const maxon::NimbusBaseRef nimbusRef = e.GetValue().GetBase(); ApplicationOutput("NodeSpace ID: @"_s, key); }
I get the following errors in my code.
Error C2079 'nimbusRef' uses undefined class 'maxon::NimbusBaseRef' Error C2027 use of undefined type 'maxon::NimbusBaseRef'
I have the nodes.framework and the graph framework installed (and actually use it in places as well). But looking through the maxon code I can't find where NimbusBaseRef is supposed to be defined.
I see the following in operatingsystem.hclass NimbusBaseRef; using NimbusForwardRef = ForwardRefWithExtraBase<NimbusRef, NimbusBaseRef>;
Is there some other framework that I am supposed to use so that this code will compile?
I tend to find this a lot with the documentation, where it will have the code I need, but not tell me the header file to include, or the required framework to use it.Thanks.
edited by @ferdinand:
@kbar wrote:
Actually looks like I don't have the graph.framework for this project. I will add that and see if it fixes the issue.
Unfortunately adding graph.framework did not fix the issue.
I case anyone is reading this I went back to using the following alternative, checking for an exact node space to see if it is what I am looking for, in this case redshift.
BaseMaterial *pMat = //the passed in material Int32 matID = pMat->GetType(); Bool isRSNode = false; // Documentation states this is always safe to cast NodeMaterial* pNodeMat = static_cast<NodeMaterial*>(pMat); if (matID == Mmaterial) { if (pNodeMat->HasSpace(maxon::Id("com.redshift3d.redshift4c4d.class.nodespace"))) isRSNode = true; }
-
Hello @kbar,
Thank you for reaching out to us. As declared in our Support Procedures, a support request should be a singular question in a singular posting. We do not allow development-diary-style topics as it makes topics harder to read for us and more importantly future readers with the same question.
Please consolidate updates to a question into the most recent posting in a thread. I have done this here for you, but please do it yourself in the future.
About your Question(s)
NimbusBaseInterface
is subject of the 2024.3 ABI compatibility issue described here. The hotfix will come for this today, I highly recommend updating to 2024.3.2 when doing anyNimbusBaseInterface
debugging (or use 2024.2 or lower versions).You do not show us your full code, so I can only speculate based on the errors. The ABI issue does not seem to be your problem here, as you show us compilation problems and not runtime problems. It looks like that you simply did not
#include "maxon/nimbusbase.h"
which contains theNimbusBaseInterface
you want to draw a reference from.NimbusBaseRef
is a reference ofNimbusBaseInterface
and as (almost) always in the Maxon API, one must include the definition of the interface when using a reference. The reference is defined automatically upon compilation by the source processor and not part of the docs (a flaw we are aware of). The filenimbusbase.h
is part of thenodespace.framework
which you can find out by first searching for the file in our docs and then looking at the document tree.Cheers,
FerdinandPS: You can use the MaterialNodeSpaces registry to iterate over all node spaces which are loaded in a Cinema 4D instance. Despite its name, the registry will also contain non-material node spaces, i.e., the scene nodes node space.
-
Thanks @ferdinand,
I thought it must have been a missing framework, my eyes just didn't see nodespace.framework in the frameworks folder otherwise I would have tried that.
Adding the nodespace.framework and including "maxon/nimbusbase.h" is what did the trick.
Sharing my full code wouldn't have helped, since the issue was that I didn't have the framework, otherwise I would have found the header file during my searches.
It would be great if the documentation samples could somehow also mention what frameworks they require to get them to run.
Unfortunately I won't be able to use it due to the use of the nodespace.framework, since I am still providing supporting back to R20 and it gets messy altering/swapping out projectdefinition.txt files to support additional frameworks.
Also thanks for the tip on the MaterialNodeSpaces registry, although I have no idea how to use that at all. But will keep it in mind for future.
My intention was not to write a diary. I was just trying to provide as much information as I could. Since it seemed simple, and it was... ie missing framework.
I sometimes forget that this site is no longer a community and is really just a support system. I am still used to the old days of being able to provide info and have discussions with other developers. I will refrain from doing this from now on.
Thanks again!
Kent -
Hey @kbar,
My intention was not to write a diary. I was just trying to provide as much information as I could. [...] I am still used to the old days of being able to provide info and have discussions with other developers. I will refrain from doing this from now on.
Discussions are still allowed The only thing we ask for is that people consolidate their postings when possible, so that future readers have it easier assessing the relevance of a topic. After the initial question/answer pattern there are many threads here which discuss the pros- and cons of different approaches.
This forum has always been a knowledgebase which requires some concessions regarding how organic discussions can be lead here. But I think we are still very liberal compared to platforms like stack overflow or the Microsoft developer communities.
Sharing my full code wouldn't have helped, since the issue was that I didn't have the framework, otherwise I would have found the header file during my searches.
While we unfortunately do not lead with a good example ourself, case and point our C++ docs, executable code always helps. In this case I would have seen which files you include and thereby could have been more certain in what the problem was.
Regarding the C++ docs code examples: In the specific case, the example is embedded in the source code, so there is no complete code. It has been put there by some developer who thought the context is "obvious". We also have the phenomenon, a code example without its includes/context, sometimes in the manuals. There complete files do exist, but it in the past it has been often so that manual examples were written in gigantic files, and then only including snippets of them. Which makes it not so easy to include the includes and context for each example. I though more than once about also shipping the quite substantial codebase that is our manual examples, but we have decided against it for now.
I however always include includes and how to gather certain inputs when writing new code examples, as this was indeed a bad habit of omitting them.
Also thanks for the tip on the MaterialNodeSpaces registry, although I have no idea how to use that at all. But will keep it in mind for future.
A registry implements an iterator among other things and when you look at MaterialNodeSpaces you can see that it holds
NodeSpaceRef
, i.e., references toNodeSpaceInterface
instances:// Iterates over all registered node spaces. Despite its name will also include non-material nodespaces. for (const maxon::nodes::NodeSpaceRef space: maxon::nodes::MaterialNodeSpaces) { ApplicationOutput("Node space: @", space.GetId()); }
Cheers,
Ferdinand -
Thanks @ferdinand! Appreciate everything you do. Also what the rest of the sdk support and docs team are doing! Not an easy job keeping on top of all these changes.