Creating Multiple Descriptions
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2012 at 11:20, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;---------
Hey guys,I'm having some trouble setting up my loop to create multiple sliders on my Tag Plugin.
What I'm trying to do it use the value of an EDITTEXT gizmo to determine how many new slider gizmos to create in the tag's AM.I'm having problems getting the for loop (i) syntax thing to work with the description code.
I hope you understand what I mean.
Example : BaseContainer *bc(i) will create a new container for every loop iteration.
That one is easy. But I'm having trouble getting the other things to work in my loop.Here's the code in my GetDDescription() method that creates a single slider.
I need to figure out how to convert this code using the (i) syntax on the various lines of code so it creates multiple sliders:LONG index = data->GetReal(MYNUMERIC); //Get the numeric value from this GUI item to determin how many sliders to create GePrint(LongToString(index)); Bool initNewBc = FALSE; //A switching variable to be used later on BaseContainer newBc; //Create a new container to hold the new slider's data for (int i=0; i<index; i++) { DescID newCid = DescLevel(index,DTYPE_REAL,0); if (!singleid || cid.IsPartOf(*singleid,NULL)) //important to check for speedup c4d! { if (!initNewBc) { initNewBc = TRUE; newBc = GetCustomDataTypeDefault(DTYPE_REAL); newBc.SetLong(DESC_CUSTOMGUI,CUSTOMGUI_REALSLIDER); newBc.SetReal(DESC_MIN,0.0); newBc.SetReal(DESC_MAX,1.0); newBc.SetReal(DESC_STEP,0.01); newBc.SetLong(DESC_UNIT,DESC_UNIT_PERCENT); newBc.SetLong(DESC_ANIMATE,DESC_ANIMATE_ON); newBc.SetBool(DESC_REMOVEABLE,TRUE); } newBc.SetString(DESC_NAME,"New Slider"); newBc.SetString(DESC_SHORT_NAME,"New Slider"); if (!description->SetParameter(newCid,newBc,DescLevel(ID_OBJECTPROPERTIES))) return FALSE; //Update the changes made to the container } } flags |= DESCFLAGS_DESC_LOADED; return TRUE;
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2012 at 12:25, xxxxxxxx wrote:
Never mind guys.
I think I've got it now.LONG index = data->GetReal(MYNUMERIC); //Get the numeric value from this GUI item to determin how many sliders to create GePrint(LongToString(index)); Bool initNewBc = FALSE; //A switching variable to be used later on for (int i=0; i<index; i++) { BaseContainer newBc(i); DescID newCid = DescLevel(i,DTYPE_REAL,0); if (!singleid || newCid.IsPartOf(*singleid,NULL)) // important to check for speedup c4d! { if (!initNewBc) { initNewBc = TRUE; newBc = GetCustomDataTypeDefault(DTYPE_REAL); newBc.SetLong(DESC_CUSTOMGUI,CUSTOMGUI_REALSLIDER); newBc.SetReal(DESC_MIN,0.0); newBc.SetReal(DESC_MAX,1.0); newBc.SetReal(DESC_STEP,0.01); newBc.SetLong(DESC_UNIT,DESC_UNIT_PERCENT); newBc.SetLong(DESC_ANIMATE,DESC_ANIMATE_ON); newBc.SetBool(DESC_REMOVEABLE,TRUE); } newBc.SetString(DESC_NAME,"New Slider"); newBc.SetString(DESC_SHORT_NAME,"New Slider"); if (!description->SetParameter(newCid,newBc,DescLevel(ID_OBJECTPROPERTIES))) return FALSE; //Update the changes made to the container } initNewBc = FALSE; } flags |= DESCFLAGS_DESC_LOADED; return TRUE;
I'm not sure if this is correct. But it seems to be working.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2012 at 23:36, xxxxxxxx wrote:
I wouldn't start my Description indexing at 0. It should start at 1000 or you might end up messing with base description elements (such as those in Tbase and so on).
You can save memory and time by declaring the BaseContainer newBC outside of the loop and initializing it once outside as well (and then you don't have to check in the loop either). You can change the container values (such as the name and short name) inside the loop as you're doing now.
Otherwise, everything looks good.
LONG index = data->GetReal(MYNUMERIC)+1000L; //Get the numeric value from this GUI item to determin how many sliders to create GePrint(LongToString(index)); BaseContainer newBc; newBc = GetCustomDataTypeDefault(DTYPE_REAL); newBc.SetLong(DESC_CUSTOMGUI,CUSTOMGUI_REALSLIDER); newBc.SetReal(DESC_MIN,0.0); newBc.SetReal(DESC_MAX,1.0); newBc.SetReal(DESC_STEP,0.01); newBc.SetLong(DESC_UNIT,DESC_UNIT_PERCENT); newBc.SetLong(DESC_ANIMATE,DESC_ANIMATE_ON); newBc.SetBool(DESC_REMOVEABLE,TRUE); for (int i=1000L; i<index; i++) { DescID newCid = DescLevel(i,DTYPE_REAL,0); if (!singleid || newCid.IsPartOf(*singleid,NULL)) // important to check for speedup c4d! { newBc.SetString(DESC_NAME,"New Slider"); newBc.SetString(DESC_SHORT_NAME,"New Slider"); if (!description->SetParameter(newCid,newBc,DescLevel(ID_OBJECTPROPERTIES))) return FALSE; //Update the changes made to the container } } flags |= DESCFLAGS_DESC_LOADED; return TRUE;
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/03/2012 at 08:29, xxxxxxxx wrote:
Thanks for the tips Robert.
After I got to the point where I could spawn as many sliders as I wanted. I then suddenly realized that I didn't know how to actually target them.I was going to try and figure that one out today.
I was thinking that I'll have to use the index numbers of the BC to grab each of the dynamically spawned sliders...But that's just a wild guess.I also wanted to contact you via e-mail today about something else.
I'm trying to add images to my Tag's AM. And all I have to work from is old code that you & Matthias posted in the archives. Which is the old code that doesn't work anymore in R12.
I've got it all converted and it does compile. But it's crashing on me for some reason. I was going to try and PM or e-mail you today and ask you if you had a small, more recent, example I could look at to see what I'm doing wrong.-ScottA
*Update- Got everything figured out and working today. Life is Good
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/03/2012 at 17:27, xxxxxxxx wrote:
The index numbers assigned to the Descriptions should be used to access the description elements. That is why these numbers need to be unique for the tag (or for any other plugin object using descriptions). I set aside a number space for variable numbers of description elements like this. You use an enum to declare the starting number and use the count (as you already do) to determine the number of description elements.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/03/2012 at 18:26, xxxxxxxx wrote:
Hi folks,
WickedP here from the Cafe and CGSociety... hope users don't mind, don't wish to hijack, but I've been playing around with description elements much like Scott has and t'was wondering if I could get a bit of a hand. I've got a description element with a switch bool but I seem to be having trouble getting the switch bool to work through a message function (or a button).
I could decipher what I need using Scott's example above, so if someone was able to post a simple switch case that would work using Scott's code I could adapt that to mine. My elements won't add when I'm using the switch bool, but if I don't have it, my console goes crazy when I mouse over the object and do things like that (i.e. it gets caught in the loop and repeats)!!
What do I need to do to get the switch bool working effectively? Everything else on mine "seems" fine...
Kind regards,
WP. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/03/2012 at 20:11, xxxxxxxx wrote:
If you have everything working the same way as my code. But just want to add sliders using a button code that's in the message() method. Maybe you'll find this an easy way to use what you already have:
Bool SimpleTag::Message(GeListNode *node, LONG type, void *data) { BaseContainer *bc = ((BaseList2D* )node)->GetDataInstance(); //Get the container for the tag LONG index = bc->GetReal(MYNUMERIC); //The edittext GUI that adds new sliders in the GetDDescription() method switch (type) { case MSG_DESCRIPTION_COMMAND: // MSG_DESCRIPTION_COMMAND is send when button is clicked { DescriptionCommand *dc = (DescriptionCommand* )data; // data contains the description ID of the button LONG button = dc->id[0].id; // get the ID of the button switch (button) // check for different button IDs { case BUTTON1: GePrint("Button1 was pushed"); bc->SetReal(MYNUMERIC, index+1); //Adds a new slider to the tag break; case BUTTON2: GePrint("Button2 was pushed"); break; } } } tag->SetDirty(DIRTYFLAGS_DATA); //Used to update a Tag's AM GUI items return TRUE; }
Doing it this way means that you have two ways to add new sliders. Either with a button, or with the edit text gizmo.
If you don't like the edit text gui being there. Rather than deleting it you can hide it from the user using the hidden option.
That way if you decide you need it one day. It will already be there in your code and you can just unhide it.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/03/2012 at 06:30, xxxxxxxx wrote:
Thanks for your reply Scott! It's helped sort a few things out and cleaned my code up a bit. Much appreciated. I definately haven't quite got something right somewhere though. My description keeps loading in a loop everytime I mouse over the object or change an element in the object itself (like a slider value). I'll have to pick this up again in the morning, but it's irritating - it's probably just one line that's typed incorrectly!
I would post the code but unfortunately I went a bit over board in my experimental object and made 900 lines of code in the dynamic element before nailing this part. I might have to strip it down and make a duplicate with just an element or two and compare to the above code again, or post that for scrutiny instead. Will have a think.
Cheers, WP -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/03/2012 at 08:16, xxxxxxxx wrote:
I have a little tag plugin that I've built for myself that doesn't really do anything. It just has some GUI things in it. With comments in it that reminds me how the various GUI's work.
When I learn how to do something new. I add it to that tag. So I have a working example to cut and paste from when I need it.Here's that tag compiled to run in C4D32bit. And I put a copy of the source code in there too:https://sites.google.com/site/scottayersmedia/TagExample.zip
Hope that helps make it easier.
-ScottA -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/03/2012 at 04:13, xxxxxxxx wrote:
Thanks for your efforts again Scott,
It's interesting to see the small variations in our codes. Good to know there's more than one way to skin a plugin!
I've managed to stop the console going nuts. All I'm left with now is an unfriendly first slider bar that seems to take it's value from each time a new slider is added (e.g. 6 sliders means first slider value is 600%, and if I manually change it all the sliders disappear...!). and a group that's bigger than what I want it to be in the AM.
Other than that, everything's coming along OK!
WP.