GvOperatorData Plugin: can't GetString



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

    On 28/08/2009 at 19:04, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:      
    Language(s) :

    ---------
    Hello All,

    I'm writing a custom GvOperatorData plugin and running into a problem where I could not read a FILENAME/STRING input port on my node.

    Here is my code snippet:

    > \> \> CONTAINER gvmynode \> { \>         NAME gvmynode; \>         INCLUDE GVbase; \> \>         GROUP \>         { \>                FILENAME GV_MY_NODE_FILE      { INPORT; } \>                MATRIX GV_MY_NODE_MATRIX   { OUTPORT; } \>         } \> } \> \> \> Bool MyNode::InitCalculation (GvNode\* bn, GvCalc\* calc, GvRun\* run) \> { \>      m_fileValue = bn->AllocCalculationHandler(GV_MY_NODE_FILE, calc, run, 0); \>      if (!m_fileValue) \>           return FALSE;      \>       \>      return TRUE; \> } \> \> void MyNode::FreeCalculation (GvNode\* bn, GvCalc\* calc) \> { \>      bn->FreeCalculationHandler(m_fileValue); \> } \> \> Bool MyNode::Calculate (GvNode\* bn, GvPort\* port, GvRun\* run, GvCalc\* calc) \> { \>      if (!port) \>           return TRUE; \>       \>      if (!m_fileValue->Calculate(bn, GV_PORT_INPUT, run, calc)) \>           return FALSE; \> \>      String file; \>      if (!m_fileValue->GetPort()->GetString(&file;, run)) \>      { \>           return FALSE; \>      } \> \>         ... \> }           \> \>

    It seems the GetString call in Calculate always fails regardless the the file input port is connected or not. Am I missing something here? I would appreciate any help very much!

    Thanks,
    WQiao



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

    On 31/08/2009 at 03:08, xxxxxxxx wrote:

    Getting a filename string is a bit more involved. use the GvGetPortGeData helper function to fill result with the filename. You can then get the string with result.GetFilename().GetString()

    > \> CONTAINER print_node \> { \>      NAME print_node; \>      INCLUDE GVbase; \>       \>      GROUP ID_GVPROPERTIES \>      { \>           FILENAME PRINT_NODE_INPUT { INPORT; STATICPORT; CREATEPORT; } \>      } \> } \>

    > \> Bool GvGetPortGeData(GvNode\* node, GvPort\* port, GvRun\* run, GeData &result;) \> { \>      if (!node || !port) return FALSE; \> \>      GvPortDescription pd; \>      if (!node->GetPortDescription(port->GetIO(), port->GetMainID(), &pd;)) return FALSE; \> \>      GvDataInfo\* info = GvGetWorld()->GetDataTypeInfo(pd.data_id); \>      if (!info) return FALSE; \> \>      GvDynamicData data; \>      GvAllocDynamicData(node, data, info); \> \>      if (!port->GetData(data.data, data.info->value_handler->value_id, run)) return FALSE; \> \>      CUSTOMDATATYPEPLUGIN\* pl = FindCustomDataTypePlugin(data.info->data_handler->data_id); \>      if (!pl) return FALSE; \> \>      GeData ge_data; \>      if (!CallCustomDataType(pl, ConvertGvToGeData)(data.data, 0, ge_data)) return FALSE; \> \>      result = ge_data; \> \>      return TRUE; \> } \> \> Bool PrintNode::Calculate(GvNode \*bn, GvPort \*port, GvRun \*r, GvCalc \*c) \> { \>      if (!v1->Calculate(bn,GV_PORT_INPUT,r,c)) return FALSE; \> \>      if (!GvGetPortGeData(bn, v1->GetPort(), r, result)) return FALSE; \> \>      return TRUE; \> } \>

    cheers,
    Matthias



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

    On 31/08/2009 at 12:40, xxxxxxxx wrote:

    Thanks you, Matthias. Your method worked!

    However I'm running into some problem when trying to use the same method to add a BASETIME input port to the node. I could only get correct values from the port when it's not connected. If the port is connected to the Time node, the input values do not change while scrubbing the time. I was wondering if you could help.

    > `

      
    \>  CONTAINER gvmynode  
    \>  {  
    \>    
    \>          NAME gvmynode;  
    \>          INCLUDE GVbase;  
    \>    
    \>          GROUP  
    \>          {  
    \>                 FILENAME GV_MY_NODE_FILE { INPORT; STATICPORT; CREATEPORT; }  
    \>                 BASETIME GV_MY_NODE_TIME { INPORT; STATICPORT; CREATEPORT; }  
    \>                 MATRIX GV_MY_NODE_MATRIX   { OUTPORT; }  
    \>          }  
    \>  }  
    \>    
    \>  Bool MyNode::Calculate (GvNode* bn, GvPort* port, GvRun* run, GvCalc* calc)  
    \>  {  
    \>          ...  
    \>    
    \>       if (!m_timeValue->Calculate(bn, GV_PORT_INPUT, run, calc))  
    \>            return FALSE;  
    \>    
    \>       GeData timeData;  
    \>       if (!GvGetPortGeData(bn, m_timeValue->GetPort(), run, timeData))  
    \>            return FALSE;  
    \>    
    \>       Real time = timeData.GetTime().Get();          
    \>          ...  
    \>  }  
    \>    
    \>  
    

    `

    Thanks very much!
    WQiao


Log in to reply