Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    port->SetObject

    SDK Help
    0
    2
    181
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 21/06/2004 at 09:47, xxxxxxxx wrote:

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

      ---------
      port->SetObject( (BaseList2D* ) result_Object, run ) )

      No matter how I use SetObject it always returns false. Ideas, examples?

      Thanks!

      Best Regards,
      darf - coreaudiovisual, cidertank

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 22/06/2004 at 22:57, xxxxxxxx wrote:

        Sorry, I can't confirm that. This code seems to work:

            
            
            // GvTest1.cpp  
            #include "c4d.h"  
            #include "c4d_operatordata.h"
            
            
            
            
            #include "GvTest1.h"
            
            
            
            
            GeData GvGetPortGeData(GvNode* node, GvPort* port, GvRun* run)  
            {  
              if (!node || !port) return GeData();  
                
              GvPortDescription pd;  
              if (!node->GetPortDescription(port->GetIO(), port->GetMainID(), &pd)) return GeData();  
                
              GvDataInfo* info = GvGetWorld()->GetDataTypeInfo(pd.data_id);  
              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->data_handler->data_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;  
                
              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);  
                
              CUSTOMDATATYPEPLUGIN* pl =  
                FindCustomDataTypePlugin(data.info->data_handler->data_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;  
            }
            
            
            
            
            const GvOperatorID GVTEST1_ID = 1016192; // From PluginCafe!
            
            
            
            
            static LONG input_ids[] = { INPORT_LINK, 0 }; // Use this for the input ports!  
            enum { INPORT_LINK_INDEX };
            
            
            
            
            class KaaGvRef1 : public GvOperatorData  
            {  
              // Defines super  
              INSTANCEOF(KaaGvRef1, GvOperatorData)  
            public:  
                
              virtual Bool iCreateOperator(GvNode *bn)  
              {  
                BaseContainer* data = bn->GetOpContainerInstance();  
                if (!data) return FALSE;  
                  
                // data->Set  
                  
                return SUPER::iCreateOperator(bn);  
              }  
                
                
                
              Bool InitCalculation(GvNode *bn, GvCalc *c, GvRun *r)  
              {  
                return GvBuildInValuesTable(bn, ports, c, r, input_ids);     
              }  
                
                
              void FreeCalculation(GvNode *bn, GvCalc *c)  
              {  
                GvFreeValuesTable(bn, ports);  
              }  
                
              Bool Calculate(GvNode *bn, GvPort *port, GvRun *run, GvCalc *calc)  
              {  
                if (!port) return FALSE;  
                  
                BaseContainer *data = bn->GetOpContainerInstance();  
                if (!data) return FALSE;  
                  
                GvValue* vinport = ports.in_values[INPORT_LINK_INDEX];  
                if (!vinport) return FALSE;   
                  
                if (!vinport->Calculate(bn, GV_PORT_INPUT, run, calc, 0)) return FALSE;  
                  
                GvPort* inport = vinport->GetPort();  
                GeData inportdata = GvGetPortGeData(bn, inport, run);  
                  
                BaseDocument* doc = bn->GetNodeMaster()->GetDocument();  
                if (!doc) return FALSE;  
                  
                BaseLink* link = inportdata.GetBaseLink();  
                if (!link) return FALSE;  
                  
                BaseList2D* list = link->GetLink(doc);  
                if (!list) return FALSE;  
                  
                switch(port->GetMainID())  
                {  
                case OUTPORT_OBJECT:  
                  {  
                    BaseObject* obj = static_cast<BaseObject*>(list);  
                    return port->SetObject(obj, run); // GvSetPortGeData(GeData(bl), bn, port, run);  
                  }  
                }  
                  
                return FALSE;  
              }  
                
              static NodeData* Alloc(void) { return gNew KaaGvRef1; }  
                
            private:  
              GvValuesInfo ports;  
            };
            
            
            
            
            const LONG ID_GV_OPGROUP_MY = 1016194;  
            const LONG ID_GV_OPCLASS_MY = 1016193;
            
            
            
            
            static const String* GetMyGroupName()  
            {  
              static String mygroup("My Group");  
              return &mygroup;  
            }
            
            
            
            
            static BaseBitmap* GetMyGroupIcon()  
            {  
              // Never used  
              static AutoAlloc<BaseBitmap> icon;  
              if (!icon) return NULL;  
              if (icon->GetBw() == 0)  
              {  
                icon->Init(24, 24);  
                icon->Clear(200, 0, 0);  
              }  
              return icon;  
            }
            
            
            
            
            static const String* GetMyClassName()  
            {  
              static String mygroup("My Class");  
              return &mygroup;  
            }
            
            
            
            
            static BaseBitmap* GetMyClassIcon()  
            {  
              // Never used  
              static AutoAlloc<BaseBitmap> icon;  
              if (!icon) return NULL;  
              if (icon->GetBw() == 0)  
              {  
                icon->Init(24, 24);  
                icon->Clear(0, 0, 200);  
              }  
              return icon;  
            }
            
            
            
            
             
            
            
            
            
            Bool RegisterGvTest1()  
            {  
              static AutoAlloc<BaseBitmap> icon;  
              if (!icon) return NULL;  
              if (icon->GetBw() == 0)  
              {  
                icon->Init(24, 24);  
                icon->Clear(100,200, 0);  
              }  
                
              static GV_OPCLASS_HANDLER myclass;  
              myclass.class_id = ID_GV_OPCLASS_MY;  
              myclass.GetName = GetMyClassName;  
              myclass.GetIcon = GetMyClassIcon;  
                
              if (!GvRegisterOpClassType(&myclass, sizeof(myclass))) return FALSE;  
                
              static GV_OPGROUP_HANDLER mygroup;  
              mygroup.group_id = ID_GV_OPGROUP_MY;  
              mygroup.GetName = GetMyGroupName;  
              mygroup.GetIcon = GetMyGroupIcon;  
                
              if (!GvRegisterOpGroupType(&mygroup, sizeof(mygroup))) return FALSE;;  
                
              return GvRegisterOperatorPlugin(  
                GVTEST1_ID, "GvTest1", 0,  
                KaaGvRef1::Alloc, "GvTest1", 0,  
                ID_GV_OPCLASS_MY, ID_GV_OPGROUP_MY, ID_GV_IGNORE_OWNER, icon);  
            }
            
            
            
            
            // GvTest1.str   
            STRINGTABLE GvTest1  
            {  
              GvTest1 "GvTest1";  
              INPORT_LINK "in";  
              OUTPORT_OBJECT "out";  
            }
            
            
            
            
             
            
            
            
            
            //GvTest1.h  
            #ifndef _GvTest1_H_  
            #define _GvTest1_H_  
            enum  
            {  
              INPORT_LINK = 3000,  
              OUTPORT_OBJECT = 4000  
            };  
            #endif
            
            
            
            
             
            
            
            
            
            // GvTest1.res  
            CONTAINER GvTest1  
            {  
              NAME GvTest1;  
              INCLUDE GVbase;
            
            
            
            
              GROUP ID_GVPORTS  
              {  
                LINK INPORT_LINK {INPORT; STATICPORT; CREATEPORT;}  
                GVGENERALOBJECT OUTPORT_OBJECT {OUTPORT; STATICPORT; CREATEPORT;}  
              }  
            }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post