how to use user custom area
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 03:06, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform:
Language(s) : C.O.F.F.E.E ;---------
I'm going crazy to set a bitmap image for a custom user area.
i'm not using pyton or c++ but normal c.o.f.f.e.e. language.
Please any example? Big thanks -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 08:51, xxxxxxxx wrote:
Here's a simple example using a Button , Textbox, and a UserArea.
Note the path to the bitmap image is at the end of the script:// be sure to use a unique ID obtained from www.plugincafe.com var PLUGIN_ID = 10000010; // be sure to use a unique ID obtained from www.plugincafe.com enum { But_clicked, // This is the ID name I gave my Button. Use whatever name you want DLG_EDIT_BOX = 1000, _DUMMY_ // This is needed for the enum type to work. } // global variables var bmp; var text; // definition of my user area class MyUserArea : GeUserArea { public: MyUserArea(id,dialog); Init(); GetUserWidth(); GetUserHeight(); Draw(x1,y1,x2,y2); } MyUserArea::MyUserArea(id,dialog) { super(id,dialog); } MyUserArea::Init() { } MyUserArea::GetUserWidth() { return 128; } MyUserArea::GetUserHeight() { return 128; } MyUserArea::Draw(x1,y1,x2,y2) { OffScreenOn(); SetClippingRegion(x1,y1,x2,y2); DrawBitmap(bmp, 0, 0, 127, 127, x1, y1, x2, y2, BMP_NORMALSCALED); } class MyDialog : GeDialog // definition of my Dialog class { private: var ua; public: MyDialog(); CreateLayout(); Init(); Command(id,msg); } MyDialog::MyDialog() { super(PLUGIN_ID); ua=NULL; } MyDialog::CreateLayout() { SetTitle("Test Bitmap Dialog"); AddUserArea(5000,BFH_SCALEFIT|BFV_SCALEFIT,0,0); ua = new(MyUserArea,5000,this); AddEditText(DLG_EDIT_BOX, 0, 200, 0); AddButton(But_clicked, BFH_SCALEFIT, 250, 20, "Click Me"); return TRUE; } MyDialog::Init() { return TRUE; } MyDialog::Command(id,msg) { var doc = GetActiveDocument(); if (id == DLG_EDIT_BOX) //you got input from the text edit box. { text = GetString(DLG_EDIT_BOX); //grab the string from the edit box and store it into the text variable. var len = sizeof(text); //find the size of the string (strlen for the C programmers) } if(id == But_clicked) { println("Button Clicked"); var obj = doc->GetActiveObject(); if(!obj) { TextDialog("No Cube object was selected\n" + "Please select one", DLG_OK + DLG_ICONEXCLAMATION); return; } obj#PRIM_CUBE_DOFILLET=TRUE; SetString(DLG_EDIT_BOX, "It Worked!"); } EventAdd(); } class MyMenuPlugin : MenuPlugin { public: MyMenuPlugin(); GetID(); GetName(); GetHelp(); Execute(doc); RestoreLayout(secret,subid); } MyMenuPlugin::MyMenuPlugin() { super(); } MyMenuPlugin::GetID() { return PLUGIN_ID; } MyMenuPlugin::GetName() { return "Test bitmap Dialog"; // The name shown in plugins menu } MyMenuPlugin::GetHelp() { return "Shows programming of bitmap area"; } var d; MyMenuPlugin::Execute(doc) { d->Open(TRUE,-1,-1); } MyMenuPlugin::RestoreLayout(secret,subid) { if (!d) d = new(MyDialog); d->RestoreLayout(secret); } main() { d = new(MyDialog); if (!bmp) bmp = new(BaseBitmap, 128, 128); var fn = new(Filename); fn->SetFullString("c:/Test.jpg");// references the c: directory bmp->Load(fn); Register(MyMenuPlugin); }
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 09:33, xxxxxxxx wrote:
Thanks Scott one more question:
how to get the instance of a controller inside a dialog?
I mean, if i want to add a new controller as custom area at a group controller how can i do?
Thanks -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 10:16, xxxxxxxx wrote:
I'm not sure I understand your question.
When you say "controller". Are you talking about the various gizmos like: Buttons, textboxes, etc...Are you asking how to lay them out and arrange them in your dialog window?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 10:26, xxxxxxxx wrote:
yes please help me i can't figure out!
Another thing i can't do is how to call a function when a button is clicked or a textbox changes value.
Thanks and again thanks -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 11:01, xxxxxxxx wrote:
There are two types of methods to layout the gizmos in your dialog. And they depend on which way you create your gizmos.
In both methods. You use Groups to layout your dialog items.
The Coffee SDK docs also have some information on using Groups.Method#1: The internal ("Add") method.
Where you add the gizmo's code to the same file as the code that executes something.Like this:
MyDialog::CreateLayout() { SetTitle("Scale Units"); AddGroupBeginV(1000, BFH_SCALE|BFV_SCALE, 1, "", 0); { AddGroupBorder(BORDER_GROUP_IN); AddGroupBorderSpace(4,4,4,4); AddGroupSpace(4,4); AddGroupBeginV(1001, BFH_SCALE|BFV_SCALE, 2, "", 0); { AddStaticText(1002, BFH_LEFT, 0,0, "X", 0); AddEditNumberArrows(2000, BFH_SCALE, 80, 0); AddStaticText(1003, BFH_LEFT, 0,0, "Y", 0); AddEditNumberArrows(2001, BFH_SCALE, 80, 0); AddStaticText(1004, BFH_LEFT, 0,0, "Z", 0); AddEditNumberArrows(2002, BFH_SCALE, 80, 0); } AddGroupEnd(); return; }
Method#2: The external (.res file) method
Where you use a .res file to layout the gizmos.
Here is another example plugin that uses the external layout method:https://sites.google.com/site/scottayersmedia/Coffee_ResBasedMenuPlugin.zipIt might be helpful if you went to my site and download the CoffeeBible. And watched the videos. They address some of the things you've been asking about:https://sites.google.com/site/scottayersmedia/scripting
Just a word of caution.
Coffee is fading away. And Python is becoming the better choice for scripting in C4D.
But learning Coffee will help you if you decide to transition into C++ later on.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 11:15, xxxxxxxx wrote:
Yes i know already this but the problem is the group is created in design mode by resedit plugin and the custom area is added in a second time in the .cof code.
so i need to get the existing group inside the code and append the custom area.So i understand phyton is better then coffiee (someone could say that in some maxon page?? ) Now if i've to choose a new language it's better use c++ or phyton? And why?
I'm checking your website, thanks!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 12:09, xxxxxxxx wrote:
From my experience. If someone asks that question they usually aren't ready for C++ yet.
You'll probably want to use Python (or Coffee) for a while. Then if the unsupported things bother you. You can always switch to C++.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 13:40, xxxxxxxx wrote:
yes but c++ used in c4d has more feature then coffiee or python? That's the second question.
The first and more important for me was:
i need to get the existing group inside the code and append the custom area. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 14:35, xxxxxxxx wrote:
I'm not sure I understand what you're asking.
If you want to know how to add a CustomUserArea into a plugin using a .res file. Then you would need to do something like this:- Add this to one of the Groups in the .res file: USERAREA MYUSERAREA { SIZE 60, 60; }
- Add this to the .str file: IDS_MYUSERAREA " The User Area";
- Add this to your enum list in your .h file: MYUSERAREA,
The C++ SDK docs do a better job of describing these descriptions than the Coffee SDK does.
If you plan on using .res files. You'll probably want to download the C++ docs.To be honest. I don't even know if this will work properly in Coffee. I've never tried it before.
Coffee tends not to support things like CustomGUI's.
Which represents an example of how Coffee can quickly lead you into a dead end. Where using Python it should work just as well as in C++.Python in C4D isn't that far behind C++ in terms of supported options. That's it's big selling point.
If you want the maximum support. Then of course C++ is the best choice.
But with that comes the down sides of longer, more complicated code. And the need to use a compiler.
I'm not trying to talk you out of C++. I'm just saying you should see what Python can do for you first. You might be surprised how much it supports.
Then you can make an informed decision whether or not it's worth the extra time to use C++ and a compiler.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 14:57, xxxxxxxx wrote:
now i can understand why c++ is best choose for coding plugin for c4d.
now yes.
I know pretty well c++ and i know it is very power language but i didn't knew if c++ was better then coffiee on the c4d plugin SDK or if this was perfectly the same for the 3 languages. I thought languages was just a feeling choose in the case of c4d SDK but you say me no, so my choose is c++ now becouse i already know this.
i preferred coffiee becouse seem to be more simple but with same power on c4d. the answer is no, and now i know. GOOD.Now i know that, just another question for you: how is possible to create the Dialog GUI in c++ if c++ doesn't use RES files? All programatically? Thanks
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 15:28, xxxxxxxx wrote:
C++, Python, and Coffee all reference the .res files the same way.
In C++ you have the same choice whether to use the Add method in your .cpp files.
Or to use an external .res file.If you are familiar with C++ and want to pursue that direction. Then the first thing you'll need to do is download the C++ docs. Then compile the SDK found in your plugins folder.
The SDK has lots of examples you can learn from in it.If you have questions on compiling the SDK. The first part of my Intro to C++ tutorial shows how to compile the SDK.
Most of the guys in this forum are long time C++ users. And they can offer help on that better than I can.Good Luck,
-ScottA -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2011 at 15:29, xxxxxxxx wrote:
thanks for your support