Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

GetDEnabling / GetDDescription in python / c++

 Post Reply Post Reply Page  <12
Author
Message
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 9:28am
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
Back to Top
littledevil View Drop Down
Member
Member
Avatar

Joined: 2012 Feb 09
Online Status: Offline
Posts: 727
Post Options Post Options   Quote littledevil Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 10:52am
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 work

i 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


Edited by littledevil - 2012 Mar 26 at 10:52am
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Post Options Post Options   Quote ScottA Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 11:58am
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


Edited by ScottA - 2012 Mar 26 at 11:58am
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 12:22pm
Originally posted by littledevil


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
Back to Top
littledevil View Drop Down
Member
Member
Avatar

Joined: 2012 Feb 09
Online Status: Offline
Posts: 727
Post Options Post Options   Quote littledevil Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 12:34pm
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 ...)


Edited by littledevil - 2012 Mar 26 at 12:56pm
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
Back to Top
littledevil View Drop Down
Member
Member
Avatar

Joined: 2012 Feb 09
Online Status: Offline
Posts: 727
Post Options Post Options   Quote littledevil Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 26 at 12:55pm
Originally posted by spedler

Originally posted by littledevil


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.


Edited by littledevil - 2012 Mar 26 at 12:55pm
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
Back to Top
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 474
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Posted: 2012 Mar 29 at 9:56pm
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.
Back to Top
rown View Drop Down
Member
Member


Joined: 2012 Apr 24
Online Status: Offline
Posts: 100
Post Options Post Options   Quote rown Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Apr 05 at 1:55pm
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 
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2573
Post Options Post Options   Quote NiklasR Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Apr 05 at 1:59pm
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
Back to Top
rown View Drop Down
Member
Member


Joined: 2012 Apr 24
Online Status: Offline
Posts: 100
Post Options Post Options   Quote rown Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Apr 05 at 2:12pm
An one year old topic and a reply after 4min. Incredible Big smile

Thanks Niklas
rown


Edited by rown - 2013 Apr 06 at 1:07am
Back to Top
César View Drop Down
Member
Member


Joined: 2012 Jan 15
Location: France
Online Status: Offline
Posts: 36
Post Options Post Options   Quote César Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Nov 23 at 3:14am
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. : /


Edited by César - 2013 Nov 23 at 3:18am
Back to Top
littledevil View Drop Down
Member
Member
Avatar

Joined: 2012 Feb 09
Online Status: Offline
Posts: 727
Post Options Post Options   Quote littledevil Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Nov 23 at 10:45am
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 crashy

i 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 ?
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
Back to Top
César View Drop Down
Member
Member


Joined: 2012 Jan 15
Location: France
Online Status: Offline
Posts: 36
Post Options Post Options   Quote César Quote  Post ReplyReply Direct Link To This Post Posted: 2013 Nov 23 at 12:03pm
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.


Edited by César - 2013 Nov 23 at 12:04pm
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.109 seconds.