Tags to store array-Data with



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/06/2006 at 09:13, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.5 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hy fellows,
    I have to ask a question, call me stupid, but I do not know how:
    I developed an individual Tagplugin (PLuginTag derived) and I have to store some more Data in it (array of Int). SDK tells me, not to do so and I see why: It gets really, really slow. But when I do not store this array in the tagplugins Basecontainer, the data is lost after deactivating my indivual tag in the document and activating another object. When I click on my tag again, all data is gone, although the array the data is stored in is a private variable-property of my plugin (C.O.F.F.E.E.-array). Cinema seems to keep created scene-objects temporarily in memory to save more of it, right? So the created instance of my tag is destroyed when deactivated and recreated on reactivating it, am I right? Basecontainers seem to be needed to store data persistent through this process. Please correct me, if I am wrong. Storing the Coffeearray directly does not work to0: I have to store its elements with a container-elemtent-id per arrayelement to get some data back out of the container. Otherwise the BaseContainer->GetData-Function always just returns NULL. But this of course is very slow.
    But how can arraydata be stored persistent without using Basecontainers? Cinema seems to do it itself with the Polygon- or Pointtags for example and these do not seem to be slow at all to me. So if anyone has got an idea i would be greatfull for some help.
    A, well, neary forgot: The data represents the selection of Polygons in object different from the tags object. I tried to store a baseselect in the container directly but it wont work (perhaps because a BaseSelect needs a matching PolygonTag?)
    But perhaps there is another clever solution to store Polygonselections of a different object in a tag someon of you knows, so this could be very helpful too.
    Many thanks,
    EbiWahnkenobi



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/06/2006 at 11:33, xxxxxxxx wrote:

    You more than likely need to implement Copy/Save/Load from PluginTag for the Tag plugin.

    Cinema 4D does a lot of cloning (document, objects, tags, materials) - for the object cache, rendering, and other miscellaneous processes. Cloning is basically a new allocation of your plugin with BaseContainer data automatically copied. Without the Copy() implemented, any class data not stored in a BaseContainer is lost during the process. Same for retaining the data in the document file when saved and loaded.

    Almost forgot: If you allocate your array anywhere else than the constructor, you will need to allocate it for the dest copy and then copy the data from the source array to the dest array.

    Hope that helps,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/06/2006 at 02:18, xxxxxxxx wrote:

    Hello kroyume0161,
    thanks first of all for your answer. I implemented the copy-function using my property-read/write-subs to set the data from the tag to dest like this
    (Data is the local array-variable storing the information, GetData() and SetData offer access to it)
    dest->SetData(GetData())
    But still the data ist lost after deactivating the tag/tagowner and switch back on it again. I even do not need to change the scene or close the file to loose its information.  But I did not think the creation of my Data-array in the constructor yet. I think this is the source of my trouble, cause so far I created the array in the SetData-Propertyfunction if it did not exist.
    This is a fine tipp thanks a lot, I will try this out!
    Best whishes,
    Ebiwahnkenobi



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/06/2006 at 05:15, xxxxxxxx wrote:

    SetData/GetData won't work unless the tag is a VariableTag - and you can't extend Cinema 4D's types. Tags can only be extensions of BaseTag (Tbase).

    For copying the array, you'll need to do this:

    // If you don't allocate the array in the constructor, do this:  
    dest->arrayvar = new(array,sizeof(arrayvar));  
    // Copy source arrayvar to dest arrayvar  
    // 1. Using memins (haven't tried this, but looks to work)  
    var result = memins(dest->arrayvar,arrayvar,0);  
    // - OR -  
    // 2. Using a loop  
    var e;  
    for (e = 0; e < sizeof(arrayvar); e++)  
    {  
       dest->arrayvar[e] = arrayvar[e];  
    }
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/06/2006 at 06:37, xxxxxxxx wrote:

    Hy Robert,
    I will try this out. Seems quite logic to me. I fI understood you right,
    something like
    dest->SetData(GetData()) will not work properly if GetData is a my own function to return the array-property? Then I understand I think.
    By the way, do you know if it is possible to derive own Tags from the baseclass VariableTag?
    Thanks once mor for your help,
    Ebiwahnkenobi



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/06/2006 at 07:05, xxxxxxxx wrote:

    If you make your own GetData() to do the possible array allocation and copy of array elements into the new array and SetData() to point the new tag at that new array, then it will work.

    No, you cannot derive any plugin tags from anything but BaseTag (PluginTag, more specifically, being directly derived from BaseTag). Same for any plugin type. You cannot extend built-in Cinema4D objects, tags, materials, shaders, and so on. I too wish that this was possible - as it means reinventing the wheel more often than not in order to add a little functionality to something already there.



  • On 25/07/2016 at 05:43, xxxxxxxx wrote:

    No, you cannot derive any plugin tags from anything but BaseTag (PluginTag, more specifically, being directly derived from BaseTag).

    Sorry for reviving this ancient thread, but I assume this has not changed, has it?



  • On 26/07/2016 at 06:50, xxxxxxxx wrote:

    No need to be sorry, it is a valid request.
    Unfortunately I have no good news, it's still not possible. I added another feature request on this topic to our database.


Log in to reply