THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/10/2010 at 06:23, xxxxxxxx wrote:
Cinema 4D Version:
FYI, please always use SetParameter/GetParameter from now on to access parameters. Accessing the container through GetDataInstance led to some problems because a programmer can never know for sure where an object stores its data. Fiddling in the container can cancel the mechanisms used by the AM and XPresso.
On 05/11/2010 at 09:38, xxxxxxxx wrote:
sorry, I don't understand. Instead of what should GetParameter be used? What would be the replacement for
BaseContainer *bc = op->GetDataInstance();
Bool b = bc->GetBool(ID_MYBOOL);
LONG l = bc->GetLong(ID_MYLONG);
Do you mean, we cannot store and use a pointer to the BaseContainer anymore and have to code
op->GetParameter(DescLevel(ID_MYBOOL), data, DESCFLAGS_GET_0);
Bool b = data.GetBool();
op->GetParameter(DescLevel(ID_MYLONG), data, DESCFLAGS_GET_0);
LONG l = data.GetLong();
for each single parameter? A text replacement wouldn't be possible, so we would have to replace manually hundreds of lines! Additionally, a lot of functions that deal with BaseContainer pointers have to be rewritten.
On 06/11/2010 at 03:20, xxxxxxxx wrote:
Klaus, I sympathise with you very much. I was going to post something similar but didn't get round to it. The other questions of course, are does this mean that existing plugins, all using BaseContainers extensively, can be expected to fail at some point in the future with later releases of C4D? And why does the SDK tell us to use them in preference to GeData?
I too would like some more details about this.
On 08/11/2010 at 02:16, xxxxxxxx wrote:
It is still allowed to access the BaseContainer directly. In the long run it is recommended to use Set/GetParameter though. It would allow us to implement some nifty features which are otherwise not possible.
On 08/01/2011 at 16:29, xxxxxxxx wrote:
I'm new at this C++ API stuff and I just learned how to get at an object's container using the GetDataInstance() function. Only to see it's now being frowned upon.
This is simple example of using the GetDataInstance() function:
BaseObject *objCube = BaseObject::Alloc(Ocube); //Creates a cube primitive
BaseContainer *bc = objCube->GetDataInstance(); //Get the cube's container
bc->SetReal(PRIM_CUBE_SUBX,2); // number of segments
bc->SetReal(PRIM_CUBE_SUBY,5); // number of segments
bc->SetReal(PRIM_CUBE_SUBZ,2); // number of segments
doc->InsertObject(objCube, NULL, NULL, 0); // Add it to the OM
Could someone possibly convert this same code to the Get/SetParameter method so I can see how it's done?
I don't want to develop bad work habits as a beginner.
On 08/01/2011 at 23:12, xxxxxxxx wrote:
Replace the bc->SetReal() statements with these and remove the GetDataInstance() as no longer needed.
objCube->SetParameter(DescID(PRIM_CUBE_SUBX), GeData(2.0), DESCFLAGS_SET_0);
objCube->SetParameter(DescID(PRIM_CUBE_SUBY), GeData(5.0), DESCFLAGS_SET_0);
objCube->SetParameter(DescID(PRIM_CUBE_SUBZ), GeData(2.0), DESCFLAGS_SET_0);
ETA: You should be explicit about numeric types whenever possible. If you specify a 2 for a floating point value, the compiler does a conversion to float or double (which adds instruction calls). Maybe once or twice isn't bad, but consider when it is being done many times in repetitively called methods. Still, this also avoids ambiguity as in the case above which may lead to incorrect values being stored.
On 09/01/2011 at 03:47, xxxxxxxx wrote:
That's interesting, Robert. Thanks for posting it. It does seem to me though that it's a really long-winded way of going about things. The SetParameter() call involves a constructor for the DescID, and another one for the GeData. Plus it just looks clumsy and inelegant compared to the BaseContainer method.
I think that if Maxon want us to use this method, they should make GetParameter() and SetParameter() easier to use, even if they just put a wrapper round it to avoid the extra typing. Just IMHO, of course.
On 09/01/2011 at 07:14, xxxxxxxx wrote:
BTW. I don't know if you remember me or not. But I'm the guy that asked you to create your Split Selection tag maker plugin on Renderosity years ago.
That's a great little plugin that speeds up the creation of symmetrical Poser figures. And I got a lot of use out that.
On 15/01/2011 at 15:55, xxxxxxxx wrote:
What is the equivalent in Python? Doesn't appear to be a Get/SetParameter() function. From the documentation, I don't see a way of accessing values not stored in a container - such as certain compositing tag settings...
On 15/01/2011 at 16:09, xxxxxxxx wrote:
Ah, never mind... I see here:
BaseList2D.__setitem__(self, key, value)
Seems to have replaced GetParameter() and SetParameter() in python.
On 21/01/2011 at 09:23, xxxxxxxx wrote:
Remember any function surrounded by two underscores in the python api is an internal implementation with a separate syntax. For instance, __eq__(a,b) is simply telling python how to evaluate a=b for a specific class.
In this case, __getitem__ and __setitem__ simply refer to the bracket syntax. You're probably doing it right in Python already, because it's easier to do it right in Python.
So basically just use:
op[c4d.PRIM_CUBE_SUBX] = 5
subx = op[c4d.PRIM_CUBE_SUBX]
bc = op.GetDataInstance()
bc[c4d.PRIM_CUBE_SUBX] = 5
subx = bc[c4d.PRIM_CUBE_SUBX]
On 09/01/2012 at 07:08, xxxxxxxx wrote:
Hi, i have a question about this GetParameter method.
We want to retrieve information of a node from an xpresso connection.
So actually i got the node object itself and now i want to get the min and max values for a rangemapper for example. The user can input them in the bottom right corner of the cinema 4d IDE.
So i got something like this.
GeData storedData = new GeData(); // This will contain the data
if (node.GetParameter(new DescID(C4dApi.XXX), storedData, C4d.DESCFLAGS_GET.DESCFLAGS_GET_0))
int output = storedData.GetLong();
Logger.Debug("Data retrieved: " + output.ToString());
Logger.Debug("Data NOT retrieved!");
So storedData will be filled with the data required from XXX.
Please note we are wrapping the API to C# code ...
cheers and thanks!