GetDEnabling / GetDDescription in python / c++
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/03/2012 at 18:18, xxxxxxxx wrote:
hi,
i hadn't much time the last week, but i am still exploring python i still have some questions
regarding descriptions (and basecontainers). i want to hide and show a description element
depending on the state of other elements (hide element A if the boolean element B is false
for example). after some google research i found some threads here and on cgtalk regarding
this topic, but nevertheless most questions remain unanswered.> 1.is it possible to access the description element flags (DESC_HIDE for example) with
>
> python ? one older thread here on plugin cafe states that it is not. is this still true ?> 2. because here nikklas shows how to set the DESC_MAX flag for an userdata element.
>
> aren't userdata and descriptions basicly the same ?> 3. i am still not sure what an objects basecontainer contains returned by c4d.BaseList2D.
>
> _GetData(). _is it just a list of values or is it a list of base containers (containing values and
>
> the description element flags)? when i try to print the content of my plugins basecontainer
>
> with an recursion to the consle c4ds recursion overflow prevention thing stops me after a
>
> while, but when i treat the basecontainer directly like a basecontainer of basecontainers
>
> the console says element xyz is a vector(or whatever) not a list .> 4. i cannot find anything explaining c4d.descID and c4d.descLevel. the desciption in the sdk
>
> remains somehow mysterious for me about thier usage.i could post some of my code, but i think this won't help much since i do not understand some
very basic things regarding containers and descriptions. i do not expect you to do the work for
me , but some answers would be great. sorry for this mess :D.happy rendering,
ferdinand -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 02:35, xxxxxxxx wrote:
Hi Ferdinand!
-
Yes it is, but I haven't tried it out, yet. Since R13, the c4d.plugins.NodeData class provides
an overwriteable method called ~.GetDEnabling. Wonder why they didn't actually complete it
by providing the other methods this class provides in C++ (~.GetDDescription, etc.) -
Afaik, you cannot obtain the container "describing" your description. But I don't think there is
much difference internally between the description and the Userdata. -
Well, the docs say it returns a c4d.BaseContainer instance, don't they? The container you
get associates the object's parameters IDs with their values. ~.GetData() returns a copy of
that container while ~.GetDataInstance() returns the actual, real, exactly the same
container the object uses to store it's parameters. Modifieng that one will directly modify the
object's parameters.
bc = op.GetData()
bc[c4d.PRIM_CUBE_SUBX] = 10
op.SetData(bc)equal to
bc = op.GetDataInstance()
bc[c4d.PRIM_CUBE_SUBX] = 10equal to
op[c4d.PRIM_CUBE_SUBX] = 10
- It's somewhat confusing, but actually I never really needed it so I don't know much about it.
I hope this helps you a bit.
Cheers!
-Niklas -
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 04:39, xxxxxxxx wrote:
hi Niklas,
thanks for your reply.
> 1. ah there it is should have red NodeData more carefully.
> 3. ~~so GetDataInstance() returns the whole container while GetData() crops the container ~~
>
> ~~at the top level only returning the values ? i am aware of the differences (and restrictions) ~~
>
> ~~of both but i am still not quite sure what is actually contained within the basecontainer. ~~
>
> ~~i thought GetData returns a copy of the whole container, while GetDataInstance returns ~~
>
>a *pointer* to the whole container.
~~
~~
>just to make it visually clear , is it something like this :
> ~~
> ~~
>
> _basecontainer_
> > _vector value_
> > _customdatatype value_
> > > _float value_
>
>> > _float value_
> ~~
> ~~
~~
~~
>or something like this (bc is also containing description flags)
> ~~
> ~~
> _ ~~basecontainer
> ~~_
> > _element basecontainer_
> > > _vector value_
>
>> > _descriptions_
>
>> > _..._
> > _element basecontainer_
>
>> > _customdatatype value_
> > > > _float value_
>
>> > > _float value_
> > > _descriptions_
> > > _..._
> ~~
> ~~
>
>currently i do not know how to access the sub containers if there are any.
>
> ~~
> ~~
>
> problem solvedis there here thread for suggestions/mistakes for/in the python sdk ? sometimes it feels like a
jungle where some trees have a label "this is a monkey".happy rendering,
ferdinand -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 08:06, xxxxxxxx wrote:
.3 - Take a look at this thread:
https://developers.maxon.net/forum/topic/5284/5286_please-use-getparametersetparameterWe have two ways to reach parameters:
1- Through hand made BaseContainers(bc).
Or
2- Through Get&SetParameter() methods that use a DescID type of synatx.Maxon wants us to stop using those hand made containers as much as possible.
For python users. That means they want us to use this: op[c4d.PRIM_CUBE_SUBX] = 10 type of syntax as much as possible.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 09:10, xxxxxxxx wrote:
hi,
i was able to write the description states with itemdesc provided by GetDEnabling. i am not quite
sure, but this is *unwanted* useage ?def GetDEnabling(self, node, id, t_data, flags, itemdesc) : itemdesc[c4d.DESC_HIDE] = True; return False
i should use SetBool() instead of this ? i am not quite sure if it is intended that i am messing with
itemdesc. also some other things still confuse me.1. is intended that self is missing in the parameter list for GetDEnabling ? why is it listed for other
overwritable methods ? when i overwrite it without the self parameter the console says "meh, got
5 parameters , but i want 6, you suck !"
2. the descID id is actually a descLevel for me.
3. t_data is alway none for me
4. and finally (doooh :D) i do not really understand where and why i should do this :Then make sure to include a call to the parent at the end:
return NodeData.GetDEnabling(node, id, t_data, flags, itemdesc)
when i return it at the end of GetDEnabling instead of True or False for the elements enable/
disable state (which i could set with itemdesc) this would lead to an endless recursion.thanks for your help.
happy rendering,
ferdinand -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 09:22, xxxxxxxx wrote:
ok ,
is it meant this way : i should get the parent of my nodedata, and return it this way
return ParentNodeData.GetDENabling(node, id, t_data, flags, itemdesc)
however this also doesn't really make sense for me oO
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 10:32, xxxxxxxx wrote:
- No, that's an issue of the docs. For methods, there is always a self as first parameter (as long as their non-static/classmethods)
- Sure? Gonna try that out. Would be an issue of the docs again if so.
- Don't actually know what value it is intended to be. I'm not getting much information out of the C++ SDK, too. It says >Originally posted by xxxxxxxx
Just read the passed t_data if the right id was provided, and return TRUE to enable the parameter or FALSE to disable it depending on the value. Then make sure to include a call to the parent at the end:
return SUPER::GetDEnabling(node, id, t_data, flags, itemdesc);
_<_h5_>_Re_<_h5_>_/h5>
> Bool
>
>> TRUE if the parameter should be enabled, otherwise FALSE. It's is recommended that you include a call to the parent function as your lastreturn
.How should I return True or False when I need to return the value returned by the parent-call?
4. >Then make sure to include a call to the parent at the end:return base.GetDEnabling(node, id, t_data, flags, itemdesc)
That means you should call the parent's implementation of that method. The example line of code here is not the one of the yellow, as it does not correctly demonstrate how to do it. You can call a base-classes method by doing either
def GetDEnabling(self, node, id, t_data, flags, itemdesc) : # ... return NodeData.GetDEnabling(self, node, id, t_data, flags, itemdesc)
or
def GetDEnabling(self, node, id, t_data, flags, itemdesc) : # ... return super(MyNodeDataSubClass, self).GetDEnabling(node, id, t_data, flags, itemdesc)
both ways are equivalent (but the latter only applies for subclasses of the built-in object class (every class in Py4D inherits from this class, so it works. ).
Cheers,
-Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 11:00, xxxxxxxx wrote:
2. i printed the content of the parameters to the console and id always contained something
like this _[MyIDRange,LargeNumber,MyPluginID]. _plus _ _ typeof returned descLevel.4. sorry, but i still don't really get this. i understood from the documentation the placement of
the call but i don't understand how it works in conjunction with the construction of GetDEnabling.
GetDEnabling returns True|False for the state of the passed description id. when i return the
parents GetDEnabling instead it will cascade through my object hierachy but it will never set the
state of my ids. to my understanding there can always be just one return statement in a function
call as works similiar to the break statement.Enabled/disabled could be set with the desciption container, but then the naming of the method
and its description
_<_t_<__<_t_<__<_t_>_Returns:|
True if the parameter should be enabled, otherwise **False _g>.---|---
is quite misleading when the concept is to call an update the cycle as the exit statement. i can't
get rid of the feeling that i didn't understood a basic concept here.thanks for your great help,
ferdinand -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 11:05, xxxxxxxx wrote:
As you can see in point 3, I mentioned I don't understand the C++ SDK at this point, too. ^^ I don't have any Idea how I should return True or False when I should actually return the value of the parent's method. That is logically not possible.
Anyway, have you figured out any problems when not calling the parent's method and just return True or False just as you want to? I don't have time to mess around with that, sorry. A statement from the support would be nice..
Cheers,
-Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 11:05, xxxxxxxx wrote:
t_data is representing a GeData type.
It's a variable that's used to hold data.
You can think of it as being very similar to the variable bc when you create a base container.Get&SetParameter() methods use this GeData type as the variable that holds the parameters you find with them. Instead of the bc variable you're more used to using with base containers.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 12:12, xxxxxxxx wrote:
Originally posted by xxxxxxxx
As you can see in point 3, I mentioned I don't understand the C++ SDK at this point, too. ^^ I don't have any Idea how I should return True or False when I should actually return the value of the parent's method. That is logically not possible.
Anyway, have you figured out any problems when not calling the parent's method and just return True or False just as you want to? I don't have time to mess around with that, sorry. A statement from the support would be nice..
Cheers,
-Niklasit is working but it behaves a bit oddly sometimes. when a descriptions state is changed you
have to acutally click or hoover something until the changes are reflected in the gui. could be
the result of the missing parent call, or i have just to use some sort of update call after i have
changed itemdesc. haven't tested it much yet, i have moved on to the actual plugin code
already, as the gui finally is at some sort of useable state.as a side note : i know maxon bashing is generally not very appreciated ** ** in the com but the
numerous mistakes i have already found in the documenation after ~3 month of more serious
python script and python node usage plus 2 weeks of actual python plugin usage are really a
shame. you have literally just to poke somewhere randomly into the documenation to find
dozens of mistakes. i can understand when some parts of the api calls aren't working due to
the complex system of c4d, but mixing up descriptions of get and set methods, wrong method
names and much more is simply sloppy.
also leaving the actual support onto some users here doesn't shed a good light onto maxon.well, enough of pointless raging, i can just thank you both for your help again and say,
happy rendering,
ferdinand -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 13:00, xxxxxxxx wrote:
I don't know if this matters or not. But when I do this sort of thing in C++. I don't do it in the GetDEnabling() method.
I was under the impression that method was used for greying out things. So the user can't execute them.I see most people using the GetDDescription() method for dynamically hiding GUI's that are using descriptions. Like this:
Bool SimpleTag::GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags) { BaseContainer *data, *bc; //Create two empty containers const DescID *singleid; //Create a DescID variable DescID cid; //Create another DescID variable if(!description->LoadDescription(node->GetType())) return FALSE; data = ((BaseList2D* )node)->GetDataInstance();//Get the container for the tag singleid = description->GetSingleDescID(); // <---- undocumented function call //Check the state of the MYBOX checkbox GUI item and show or hide the slider GUI item as required cid = DescLevel(MYSLIDER, DTYPE_REAL, 0); //Assign the slider GUI item to this description variable if(!singleid || cid.IsPartOf(*singleid, NULL)) { bc = description->GetParameterI(cid, NULL); //Assign the slider to this DescID variable bc->SetBool(DESC_HIDE, data->GetBool(MYBOX)); //Hide the slider GUI if GetBool is true(Checkbox is enabled) } flags |= DESCFLAGS_DESC_LOADED; return TRUE; }
I have no idea how to do this in python yet. And I would love to see an example if you get it all working.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/03/2012 at 14:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I don't know if this matters or not. But when I do this sort of thing in C++. I don't do it in the GetDEnabling() method.
I was under the impression that method was used for greying out things. So the user can't execute them.it is, to my understanding now GetDEnabling is meant to be used this way in python :
when you want do enable/disable an element, then you use it whith a boolen as return
value (and you don't have to bother about the correct updates of the gui). but as soon as i
start to manipulate the itemdesc parameter i get this odd update behaviour until i use this
recursive parent call thing. can't say this is rock solid, because im still quite uncertain with python
and the api, but und it seems to be working for me now. will post a snippet later when i am sure
that i am not talking bulls**t . -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2012 at 14:33, xxxxxxxx wrote:
two things,
1. itemdesc seems to be read only, overwriting it causes major gui problems and it doesn't seem
to be the desciption of the current instance of your class, as changes to it effect all active instances
of your plugin. (also instances that are created after the changes).2. i found an example for the intended use of the return value for GetDEnabling (at least for c++)
maxon also just returns true or false.Bool DoubleCircleData::GetDEnabling(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_ENABLE flags,const BaseContainer *itemdesc) { LONG inter; BaseContainer *data = ((BaseObject* )node)->GetDataInstance(); if (!data) return FALSE; switch (id[0].id) { case SPLINEOBJECT_SUB: inter=data->GetLong(SPLINEOBJECT_INTERPOLATION); return inter==SPLINEOBJECT_INTERPOLATION_NATURAL || inter==SPLINEOBJECT_INTERPOLATION_UNIFORM; case SPLINEOBJECT_ANGLE: inter = data->GetLong(SPLINEOBJECT_INTERPOLATION); return inter==SPLINEOBJECT_INTERPOLATION_ADAPTIVE || inter==SPLINEOBJECT_INTERPOLATION_SUBDIV; case SPLINEOBJECT_MAXIMUMLENGTH: return data->GetLong(SPLINEOBJECT_INTERPOLATION)==SPLINEOBJECT_INTERPOLATION_SUBDIV; } return TRUE; }
nevertheless, i would really like to hear a word from maxon on the nature of the itemdesc
parameter and if there is a way to hide description elements per instance dynamicly with
python. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2012 at 15:21, xxxxxxxx wrote:
Lol. I can't figure out what you're trying to do.
Here's what you posted in your first post:
"is it possible to access the description element flags (DESC_HIDE for example) with python ?"This indicated to me that you want to dynamically hide and unhide GUI items.
Yet you keep on insisting to use the GetDEnabling() method to do this. But that's not what this method is for.
GetDEnabling() for greying out items so the user can't click on them. The Python docs call it "Ghosting".Here's a dynamic GUI tag plugin I made with C++ that is compiled to run under the 32 bit version of C4D:https://sites.google.com/site/scottayersmedia/TagExample.zip
Install it.. Add the tag to an object.. And try out the various GUI items to see the dynamic results.
-When you click on the checkbox. The slider disappears and the text changes in the textbox.
-When you click the first button. A new slider is created
-When you select the second combo button option. The text box disappears.
-Etc..Is this what you're trying to do?
If not. What is the end result you're trying to achieve?-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2012 at 16:52, xxxxxxxx wrote:
well, as i said , my goal is to dynamically hide and unhide GUI items. i also found your tag
example plugin and microbins plugin cookbook entry on my very first google search on this
topic, but as nikklas already said, GetDDescription isn't implemented for python. he also
pointed me to GetDEnabling. and as its description is kind of vague and the itemdesc
parameter looked promising, i tried to abuse it to set DESC_HIDE. now i gave up, because
you can hide and and unhide elements with itemdesc, but the gui doesn't update correctly
and it seems to be the description of the class itself not the description of the instance of the
class (no idea why, but when you hide parameter A, it is hidden for all instance of your plugin,
even for instances you created after the changes to the description) . so i kind of gave up and
i will use GetDEnabling as it seems to be intended to be used (for enabling/disabling elements)
although i would prefer to be able to acutally hide elements. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2012 at 17:35, xxxxxxxx wrote:
OK.
Just wanted to be sure we were still talking about hiding & and unhiding gizmos as the goal.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/03/2012 at 10:49, xxxxxxxx wrote:
i know it is a bit crazzy , but i am on c++ now. i think i will fail miserably, but nevertheless i thought
i'll have a small chance with my minor c# knowledge. so i revisited this problem and it works fine
with the GetDDescription example from Microbins Cookbook for me.
However i have really many parameters to hide and unhide so i thought it would be good to create
a metheod to shorten things a bit. unfortunately the code isn't working as expected it compiles
without errors, but it doesn't hide/unhide the elements and with c4d started from VS in debugmode
it does un/hide the targeted element ( PLIGHT_LIGHT_TYPE_OBJECT ) but not under the expected
conditions. i guess i have created some logic error i am to stupid to find or i am using pointers in a
wrong manner.the relevant code :
Bool Opolylight::GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags) { BaseContainer *data; const DescID *singleid; DescID cid; if(!description->LoadDescription(node->GetType())) return FALSE; data = ((BaseList2D* )node)->GetDataInstance(); singleid = description->GetSingleDescID(); LONG value[] = {PLIGHT_LIGHT_TYPE_OBJECT}; UnHideDescription(PLIGHT_SHAPE_OBJECT_LINK, DTYPE_BASELISTLINK, data->GetLong(PLIGHT_LIGHT_TYPE) , value, FALSE , singleid, description); flags |= DESCFLAGS_DESC_LOADED; return TRUE; } void Opolylight::UnHideDescription(LONG targetid, LONG dtype, LONG checkvalue, LONG value[], Bool isequal, const DescID *singleid, Description *description) { BaseContainer *bc; DescID cid; cid = DescLevel(targetid, dtype, 0); if(!singleid || cid.IsPartOf(*singleid, NULL)) { bc = description->GetParameterI(cid, NULL); if (isequal) { for (int i = 0; i < sizeof(value);i++) { if (checkvalue == value[i]) bc->SetBool(DESC_HIDE, TRUE); else bc->SetBool(DESC_HIDE, FALSE); } } else { for (int i = 0; i < sizeof(value);i++) { if (checkvalue != value[i]) bc->SetBool(DESC_HIDE, TRUE); else bc->SetBool(DESC_HIDE, FALSE); } } } }
UnHideDescription is meant to un/hide elements if the checkvalue equals an element from the array value (or doesn't equals if isEqual is False).
thanks for your help in advance
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 01:06, xxxxxxxx wrote:
Hi,
There's no problem at all in using a subroutine to do this. But the way it's coded is not going to work.
In GetDDescription() you create an array of LONGs - called value - with one entry. You pass that array to UnhideDescription(). But then you do this:
for (int i = 0; i < sizeof(value);i++) { if (checkvalue == value[i]) bc->SetBool(DESC_HIDE, TRUE); else bc->SetBool(DESC_HIDE, FALSE); }
I think what you're intending to do is iterate through all the members of the array value, but you can't use sizeof to do that. sizeof(value) returns the size in bytes of the array. A LONG will occupy 8 bytes (I think!) so with one member you'll be iterating from 0 to 7. There's no way of knowing what values you'll get from that, which probably explains why it doesn't work as expected.
Instead, you'll need to pass to UnhideDescription() the number of elements in the array and iterate with that.
I can't say that will make it work, but I'm sure it won't at the moment for that reason.
Steve
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 03:37, xxxxxxxx wrote:
hi,
thanks for your help. i used this construct as replacement for a for each statement, because as i
understood for each within all mircorsoft languages uses a os specific interface (IEnumerable).
is this wrong ? however the correct approach of determing the size of an array in c++ would be :LONG size = sizeof(value)/sizeof(LONG);
---------------------------------------
size = 4*1/4;is this correct ? if not, could someone be so kind and post an example for how he is dealing with
for each *situations*, or in other words , how he is iterating through an array of unknown size ?edit :
void Opolylight::UnHideDescription(LONG targetid, LONG dtype, LONG checkvalue, LONG value[], Bool isequal, const DescID *singleid, Description *description) { BaseContainer *bc; DescID cid; cid = DescLevel(targetid, dtype, 0); LONG len = sizeof(value) / sizeof(LONG); if(!singleid || cid.IsPartOf(*singleid, NULL)) { bc = description->GetParameterI(cid, NULL); if (isequal) { for (int i = 0; i < (sizeof(value) / sizeof(LONG));i++) { if (checkvalue == value[i]) bc->SetBool(DESC_HIDE, TRUE); else bc->SetBool(DESC_HIDE, FALSE); } } else { for (int i = 0; i < (sizeof(value) / sizeof(LONG));i++) { if (checkvalue != value[i]) bc->SetBool(DESC_HIDE, TRUE); else bc->SetBool(DESC_HIDE, FALSE); } } } }
using this code, it works perfectly when cinema is started by visual studio in debug mode (things are
hidden and unhide under given conditions). but when i start cinema alone there is no reaction at all.