GetDEnabling / GetDDescription in python / c++
-
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. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 09:28, xxxxxxxx wrote:
Must admit I'm not sure why it works in the debugger but not when run alone. That seems very odd. One thing to note (which I don't actually do in my tutorial) is to return from GetDDescription with a call to the parent class equivalent - see the SDK for details.
You mention IEnumerable - that's a .NET construct, it may be available in all .NET languages including managed C++, but it won't be available in plain old C++ which is what the Cinema SDK uses.
You can get the array size that way using sizeof(array)/sizeof(element). But in the Maxon SDK if you have an array which may contain a variable number of elements, IMO it's better to maintain a counter of the number of elements in it, or to use the GeDynamicArray or GeAutoDynamicArray classes, as these have functions like GetCount() which returns the number of elements.
Steve
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 10:52, xxxxxxxx wrote:
well,
after some poking arround in the code i have found out this :1. i added some console ouput within cinema and all code is execueted as expected (32/64 bit)
2. the problem seems to be connected to 32/64 bit versions of cinema, actually i made a mistake
and didn't set up my target application for debugging properly for the different platforms. so i was
debugging with c4d 32 bit while i was running c4d 64 bit from my desktop. after having fixed that
the current state is following :32 bit debug/release api - running from VS and from desktop
64 bit debug/release api - loading plugin, setting values , allocating some objects works, but this
whole UnHideDescription thing refuses to worki guess i messed up something with my 64 bit plattforms or with compiling the 64 bit versions of
the api libs. as the natural result to own failure is ranting about other people, i have to say the
whole c++ api thing is quite unsatisfying for me. i cannot understand why maxon does not provide
the compiled api libs and why maxon doesn't provide at least for their recommanded IDE VS 2005
some template projects. who wants to compile the api each time (using the sdk example projects)?so i ripped the sdk_examples appart and added the api linker links and i guess something went
wrong there. i'm sure i'll find the mistake but this is soooo unnecessary ...will stick with 32 bit for now ... and thanks again for your help steve
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 11:58, xxxxxxxx wrote:
There are instructions on Steve's site for setting up the compiler from scratch without including the API in it that I prefer to use. Although I'm using VS 2010.
This is different from the way Maxon says to do it. But I like it better.Being a total newbie. It was a little hard for me to follow Steve's notes. So I created my own cheat sheet that is easier for me to follow:
Instructions: -Create your plugin with the skeleton folder structure inside of it *** Make sure you have your main.cpp file set up. And in the source folder *** *** The main.cpp file is used to load the api .h files. As well as register your plugins*** -Put your plugin folder with the basic file structure in the C4D plugins folder -Create a new emtpy C++ project(uncheck make directory. And select the C4D plugins folder(not your new plugin folder) as the source) -Name your project the same name as your new plugin folder so it will write the solution into that folder properly -Add the Debug & Release property sheets to the project(view->otherwindows->propertymanager) by right clicking them and choose: CINEMA 4D R12\resource\_api_lib\ Then adding these files to the proper project folders: Debug | Win 32 = DebugWin32.props Debug | Win 32 = ReleaseWin32.props -Right click the source folder and choose Add Existing Project -Add your main.cpp file--->VisualStudio will load the .cpp file. And it will also add all of the .h files from the api In configuration properties General -Set Target Extension to .cdl -Set Configuration type to Dynamic Library.dll In configuration properties Debugging -Set Command to: C:\Program Files\MAXON\CINEMA 4D R12\CINEMA 4D.exe or whichever .exe version you'll launch with the debugger In configuration properties C/C++ -In command Line. Add this to the bottom window: /vmg /vms In configuration properties Linker -In General->Set Output File to the same name as your project and with the extension: .cdl -In General->Set Additional Library Directories to: C:\Program Files\MAXON\CINEMA 4D R12\resource\_api_lib -In Input-> Additional Dependencies. Add this to the list: _api_Win32_Debug.lib -in Advanced-> change Randomized Base Address to Disable Image Randomization (DYNAMICBASE:NO) DONE with 32 bit setup!! To set up 64 bit compiling we have more work to do: -From the top menu. Click the solution platforms dropdown and select Configuration Manager -On the right drop down list. Select "New" from the options.Then select x64 -Next be sure to also enable the BUild option for this new platform -Add the Debug & Release property sheets to the project just like you did with the 32 bit platform setup above -This time select these files from the _api_lib folder: Debug | Win 64 = DebugWin64.props Debug | Win 64 = ReleaseWin64.props Right click on the project in the solution window and select properties Set up the various options the same way you set up the 32 bit options with two exceptions: -In Linker->General: Set Output File to the same name as your project and with the extension: .cdl64 -In Linker Input->Additional Dependencies. Add this to the list: _api_x64_Debug.lib DONE with 32&64 bit setups!!
For compiling this way in R13.
I also have to put a copy of the projectsettings.props file from the cinema4dsdk into the project's folder.
This is done instead of the macro setup procedure the SDK says to do.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 12:22, xxxxxxxx wrote:
Originally posted by xxxxxxxx
i have to say the whole c++ api thing is quite unsatisfying for me. i cannot understand why maxon does not provide the compiled api libs and why maxon doesn't provide at least for their recommanded IDE VS 2005 some template projects. who wants to compile the api each time (using the sdk example projects)? so i ripped the sdk_examples appart and added the api linker links and i guess something went wrong there. i'm sure i'll find the mistake but this is soooo unnecessary ... will stick with 32 bit for now ... and thanks again for your help steve
In fairness, the fact that you have to compile the API for 32 and 64 bit does show that your compiler setup is working. IME the API and the example plugins just compile without any problems, so if that works then you know that any problems are down to you rather than the supplied code.
But of course, you only have to compile the AP once. After that you just tell the linker to use the now compiled libraries. Otherwise the whole compile-link-run (-crash-fix-compile, etc.) cycle would be intolerable. The tut on my site shows, as Scott says, how to set up a project from scratch but I agree that it isn't that straightforward.
Steve
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 12:34, xxxxxxxx wrote:
i have red steves tutorials, but they didn't work for me with VS 2005 as they are written for VS 2008.
when i follow these instructions (configuration type, command line paramaters, linker settings,
property manger ...) cinema gives me some couldn't find c4d.h erorrs at the end.doing basicly the same on the sdk example projects after unlaoding the api project works for me.
not sure why. i ' ll revist this thing when i have finished the plugin in greater parts but for now i'll
stick with 32 bit. i am actally not quite sure if this might fault, because if i had set up the project in a
wrong manner why is the plugin compiling and loaded under 64 bit. as i mentioned above most of
the code is actaually working (initing variables, some GetVirtualObjects output ...) -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/03/2012 at 12:55, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Originally posted by xxxxxxxx
i have to say the whole c++ api thing is quite unsatisfying for me. i cannot understand why maxon does not provide the compiled api libs and why maxon doesn't provide at least for their recommanded IDE VS 2005 some template projects. who wants to compile the api each time (using the sdk example projects)? so i ripped the sdk_examples appart and added the api linker links and i guess something went wrong there. i'm sure i'll find the mistake but this is soooo unnecessary ... will stick with 32 bit for now ... and thanks again for your help steve
In fairness, the fact that you have to compile the API for 32 and 64 bit does show that your compiler setup is working. IME the API and the example plugins just compile without any problems, so if that works then you know that any problems are down to you rather than the supplied code.
But of course, you only have to compile the AP once. After that you just tell the linker to use the now compiled libraries. Otherwise the whole compile-link-run (-crash-fix-compile, etc.) cycle would be intolerable. The tut on my site shows, as Scott says, how to set up a project from scratch but I agree that it isn't that straightforward.
Steve
both the sdk and the api project form c4d/ ressource compiled without any problems for me, the
problem is for beginners like me the insecurity - the whole process of creating a c ++ is quite
confusing for beginners, so if you could be sure that at least your api is compiled correctly or
having a solid template project without having to compile the whole api each time would be a
great help.you said it yourself in your tutorial _Maxon implies that compiling the SDK examples is a simple matter of _
_building the solution. _ you said this regarding the the complications of compling the sdk examples
with 2008 but it describes the general problem quite well. i don't see a point for further
discussions here, since maxon seems not to be interested in this point. as i said it was just
some ranting. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/03/2012 at 21:56, xxxxxxxx wrote:
Hi there littledevil and others,
don't mean to provoke any banter as such, but just thought it might be a good opprtunity to provide some "learner" input myself here - if just for others to have a read over.
I too started C++ plugin coding a few months a go and not being a coder by nature, have found it quite difficult to get on board. I also found it hard to find info on the subject in relation to c4d itself. I came across a few sites on my own but didn't really understand it all. And it wasn't until I went back over a couple of them (including Steve's and Scott's sites) a few times that things started to make a bit of sense.
I do find it a little disappointing when looking back now that I can see so many opportunities for Maxon to make plugin making a much more enjoyable experience, but has instead been left in a bit of a hole. Especially for the code-challenged like myself! However, to be fair to Maxon, not having any knowledge in C++ beforehand probably slowed my start down a lot as well. So it was a combination of both that frustrated me in the beginning. Perhaps if I had had more knowledge in C++ to begin with, I might have made more sense of the difficult language and terms. And maybe if Maxon provided well explained and commented examples I might have understood it better too.
So I can sympatise with you all if you're starting out and having troubles With that said though, I'm now a few months into it, and I feel I have enough of a grasp of the basics to atleast start my own plugins without too much of a fuss. I can make basic events happen, can build my own AM and dialog layouts etc and am on my way to building a plugin which I'm hoping might be of use to not just myself, but maybe others in the community as well! Of course time will tell on that front, but for now, I'm enjoying it, and the possibilities.
Kind regards,
WP. -
On 05/04/2013 at 13:55, xxxxxxxx wrote:
Hello everybody,
old topic, same question. Ive got a TagData and Id like to hide/unhide DescElements. Is there a python solution in the meantime? I dont want to use UserDatas, so I also started to try out GetDEnabling , but its really used for greying out.
Thanks afterwards and in advance
rown -
On 05/04/2013 at 13:59, xxxxxxxx wrote:
Hi rown,
no the required classes are not implemented in Python, yet. Maybe in R15, but I'd say it's more likely to be implemented in R16 or later.
-Niklas
-
On 05/04/2013 at 14:12, xxxxxxxx wrote:
An one year old topic and a reply after 4min. Incredible
Thanks Niklas
rown -
On 23/11/2013 at 03:14, xxxxxxxx wrote:
It seems to work now in the R15.037, since the c4d.Description class has been added.
With GetDEnabling, you get the itemdesc value and :
itemdesc[c4d.DESC_HIDE] = True
works.But, when it's hidden, there is no more the item in the GetDEnabling list, so we can't make it appear. : /
-
On 23/11/2013 at 10:45, xxxxxxxx wrote:
are you sure that there has actually changed something, because as i did describe earlier
in this thread, before R15 it was also possible to :* hide elements using the description parameter of GetDEnabling
* however these modifications did apply globally and not per instance
* reverting these changes was not always possible
* c4d did became quite crashyi also asked in the R15 SDK thread if c4d.Description does change anything about that problem
and the answer was no.is the itemdesc parameter (i think its called that way) actually a c4d.Description now or is it
still a BaseContainer ? -
On 23/11/2013 at 12:03, xxxxxxxx wrote:
Ah, indeed, sorry.
The itemdesc is still a BaseContainer.
I finally abandonned to use it (event if I used a little trick to disable the hiding by saving the itemdesc parameter and enable/disable it in an other function), because as you said, it changes the description of all the object of this type.
So I am afraid there is still no solution.