port->SetData

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

On 11/11/2002 at 19:10, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   8.012 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s) :     C++  ;  XPRESSO  ;

---------
Tring to figure out how to use the GvPort->SetData command without crashing C4D. I want to pass a BaseLink and or our own custom datatypes.
Regards,
darf - bhodiNUT

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

On 12/11/2002 at 00:09, xxxxxxxx wrote:

Sorry, I am still investigating this and the corresponding GetData() issue. Will report back as soon as I hear anything.

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

On 12/11/2002 at 10:39, xxxxxxxx wrote:

First, I guess this cannot be repeated too often:
> GV disclaimer: The GV API (everything in c4d_gv) is currently unsupported and might change in the future.
In other words, don't rely on the current GV or TP system to be either predictable, stable or consistent. I know I've told you this privately, but it deserved to be said in public as well.
That being said, I found some more information about allocating Dynamic Data within Xpresso. From studying the functions in c4d_graphview.h some things can be learned. To use GetData() you must first call GvAllocDynamicData(), then you can use data.data as d. (I couldn't get this to work though.) For GeData-Gv conversion, see the GvSetDataInContainer() implementation.

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

On 12/11/2002 at 10:46, xxxxxxxx wrote:

Quote: Originally posted by Mikael Sterner on 12  November 2002
>
> * * *
>
> That being said, I found some more information about allocating Dynamic Data within Xpresso. From studying the functions in c4d_graphview.h some things can be learned. To use GetData() you must first call GvAllocDynamicData(), then you can use data.data as d. (I couldn't get this to work though.) For GeData-Gv conversion, see the GvSetDataInContainer() implementation.
>
> * * *
OK, where is the GvSetDataInContainer() implementation?

Thanks, darf

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

On 12/11/2002 at 11:38, xxxxxxxx wrote:

Quote: Originally posted by darf on 12  November 2002
>
> * * *
>
> OK, where is the GvSetDataInContainer() implementation?
In other news: find-in-files useful for finding stuff in files... ;-)

    
    
    //c4d_graphview.h  
      
    inline Bool GvSetDataInContainer(const void* const data, GvValueID value_id, BaseContainer &bc, LONG container_id, LONG cpu_id = 0)  
    {  
     CUSTOMDATATYPEPLUGIN* pl = FindCustomDataTypePlugin(value_id); if (!pl) return FALSE;  
     GeData ge_data; CallCustomDataType(pl,ConvertGvToGeData)(data,cpu_id,ge_data);  
     bc.SetData(container_id,ge_data);  
     return TRUE;  
    }

I.e. it calls a function pointer function in the CUSTOMDATATYPEPLUGIN. I don't really know what value_id to use here for BaseLink. Perhaps something interesting can be found if browsig the Registry for e.g. C4DPL_CUSTOMDATATYPE items. (Haven't tried myself, don't have the time at the moment.)

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

On 13/11/2002 at 01:27, xxxxxxxx wrote:

Breakthrough. Here are functions for getting and setting arbitrary value types:
>

\>     
\>     
\>     GeData GvGetPortGeData(GvNode* node, GvPort* port, GvRun* run)  
\>     > {   
\>     >   if (!node || !port) return GeData();
\>     
\>     
\>     
\>     
\>       GvDataInfo* info = GvGetWorld()->GetDataTypeInfo(port->GetValueType());  
\>     >   if (!info) return GeData();
\>     
\>     
\>     
\>     
\>       GvDynamicData data;  
\>     >   GvAllocDynamicData(node, data, info);
\>     
\>     
\>     
\>     
\>       if (!port->GetData(data.data, data.info->value_handler->value_id, run)) return GeData();
\>     
\>     
\>     
\>     
\>       CUSTOMDATATYPEPLUGIN* pl =   
\>     >     FindCustomDataTypePlugin(data.info->value_handler->value_id);   
\>     >   if (!pl) return GeData();
\>     
\>     
\>     
\>     
\>       GeData ge_data;   
\>     >   if (!CallCustomDataType(pl, ConvertGvToGeData)(data.data, 0, ge_data)) return GeData();
\>     
\>     
\>     
\>     
\>       return ge_data;  
\>     > }
\>     
\>     
\>     
\>     
\>     Bool GvSetPortGeData(const GeData& ge_data, GvNode* node, GvPort* port, GvRun* run)  
\>     > {   
\>     >   if (!node || !port || !run) return FALSE;
\>     
\>     
\>     
\>     
\>       GvDataInfo* info = GvGetWorld()->GetDataTypeInfo(port->GetValueType());  
\>     >   if (!info) return FALSE;
\>     
\>     
\>     
\>     
\>       GvDynamicData data;  
\>     >   GvAllocDynamicData(node, data, info);
\>     
\>     
\>     
\>     
\>       CUSTOMDATATYPEPLUGIN* pl =   
\>     >     FindCustomDataTypePlugin(data.info->value_handler->value_id);   
\>     >   if (!pl) return FALSE;
\>     
\>     
\>     
\>     
\>       if (!CallCustomDataType(pl, ConvertGeDataToGv)(ge_data, data.data, 0)) return FALSE;
\>     
\>     
\>     
\>     
\>       if (!port->SetData(data.data, data.info->value_handler->value_id, run)) return FALSE;
\>     
\>     
\>     
\>     
\>       return TRUE;  
\>     > }
\> 
\> 

Usage for the former function:
>

\>     
\>     
\>     GvValue* vlink = NULL;  
\>     >   
\>     > vlink = ports.in_values[GVTEST_LINK_INDEX];
\>     
\>     
\>     
\>     
\>     GvPort* linkport = vlink->GetPort();  
\>     > GeData linkdata = GvGetPortGeData(bn, linkport, run);
\>     
\>     
\>     
\>     
\>     BaseLink* test = linkdata.GetBaseLink();  
\>     > if (test && test->GetLink(bn->GetNodeMaster()->GetDocument()))  
\>     >  GePrint(test->GetLink(bn->GetNodeMaster()->GetDocument())->GetName());
\> 
\> 

Usage for the latter function:
>

\>     
\>     
\>     BaseDocument* doc = bn->GetNodeMaster()->GetDocument();  
\>     > if (!doc) return FALSE;
\>     
\>     
\>     
\>     
\>     BaseObject* obj = doc->GetFirstObject();  
\>     > if (!obj) return FALSE;
\>     
\>     
\>     
\>     
\>     AutoAlloc<BaseLink> bl;  
\>     > bl->SetLink(obj);
\>     
\>     
\>     
\>     
\>     return GvSetPortGeData(GeData(bl), bn, port, run);
\> 
\> 

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

On 13/11/2002 at 08:32, xxxxxxxx wrote:

Quote: Originally posted by Mikael Sterner on 12  November 2002
>
> * * *
>
> In other news: find-in-files useful for finding stuff in files... ;-)
>
>

\> 
\> 

>
> * * *

!@#$ My apologies, DOH!!!
darf