GV_DYNAMIC_DATATYPE doesn't seem to work [SOLVED]
-
On 19/05/2015 at 03:19, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16
Platform: Mac OSX ;
Language(s) :---------
Hi,I'm adding some Xpresso nodes to my objectdata plugin.
I have a mathnode and SetParameter(GV_MATH_FUNCTION_ID, GV_MUL_NODE_FUNCTION, DESCFLAGS_SET_0) works perfectly.
However, when I try to use SetParameter(GV_DYNAMIC_DATATYPE, GV_INT, DESCFLAGS_SET_0) it does nothing. Even if I change GV_INT to 15 (the corresponding value) it does nothing.Does anybody know how to fix this?
Thanks in advance for your help and time!
Greetings,
Casimir Smets -
On 19/05/2015 at 06:49, xxxxxxxx wrote:
Hello,
could you provide us some more code so we could reproduce what you are trying to do?
Best wishes,
Sebastian -
On 19/05/2015 at 07:15, xxxxxxxx wrote:
Hi,
Here is some more code, inside MSG_DESCRIPTION_COMMAND:
BaseDocument* doc = ((BaseObject* )node)->GetDocument(); if (!doc) return false; BaseObject* op = (BaseObject* )node; if (!op) return false; ModelingCommandData cdFirstObject; cdFirstObject.doc = doc; cdFirstObject.op = op; if (SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cdFirstObject)) { BaseObject* firstObject = static_cast<BaseObject*>(cdFirstObject.result->GetIndex(0)); doc->InsertObject(firstObject, nullptr, op); if (firstObject) { XPressoTag* myXPressoTag = static_cast<XPressoTag*>(firstObject->MakeTag(Texpresso, NULL)); if (!myXPressoTag) return false; GvNodeMaster* myNodeMaster = myXPressoTag->GetNodeMaster(); if (myNodeMaster) { GvNode* mathNode = myNodeMaster->CreateNode(myNodeMaster->GetRoot(), ID_OPERATOR_MATH); if (!mathNode) return false; mathNode->SetParameter(GV_MATH_FUNCTION_ID, GV_MUL_NODE_FUNCTION, DESCFLAGS_SET_0); // Works perfectly mathNode->SetParameter(GV_DYNAMIC_DATATYPE, GV_INT, DESCFLAGS_SET_0); // Doesn't work, even not if I change GV_INT to 15 } else { return false; } } else { return false; } } EventAdd();
I hope this provides you with enough information.
Greetings,Casimir Smets
-
On 19/05/2015 at 07:43, xxxxxxxx wrote:
Hi,
It is definately something weird, in my opinion.
I've dragged all the possible data types form the math node inside the console, to check for their int values. Here is what I found:
-COLOR 3
-BOOLE 400006001
-INTEGER 15
-REAL 19
-VECTOR 23
-NORMAL 400006005
-MATRIX 25
-TIME 22However, if I use those values I can NEVER get an integer or boole.
I've tried to use the values 0-30 inside SetParameter(GV_DYNAMIC_DATATYPE) and here are my results:0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 24, 26, 27, 28, 29, 30 and 400006001 all give me REAL as result.
3 gives me a COLOR.
7 gives me an empty cycle, and for the values two link fields, I guess, where you can click a button "Open" and then you can select whatever you want on your hard disk, ... even c4d-files.
15 gives me an application error, so C4D just crashes...
22 gives me TIME.
23 gives me VECTOR.
25 gives me MATRIX.
400006005 gives me NORMAL.As you can see, this raises a big problem, if you want to add an integer-math node.
Thanks in advance for your help and answers!
Greetings,Casimir Smets
-
On 19/05/2015 at 09:05, xxxxxxxx wrote:
Hello,
I cannot confirm any problems using the value of 15 or the appropriate constant ID_GV_DATA_TYPE_INTEGER. Also I have no problems setting the value Boole with ID_GV_DATA_TYPE_BOOL.
Can you reproduce the crash using the value of 15?
best wishes,
Sebastian -
On 19/05/2015 at 09:20, xxxxxxxx wrote:
Hi,
I can reproduce it constantly :s
The next thing I will do is try to reproduce it in an empty project, to see if I still have the problem there.
I will post the result here..Thanks for your help and time!
Greetings,
Casimir Smets -
On 20/05/2015 at 06:04, xxxxxxxx wrote:
Hi,
I've tried it inside a new project, and there it works fine.
It seems to be failing by code that comes after the setting of the datatype.
If I delete that code, my problem is gone.
But, now, I'm on to the next problem, setting the second input port value.I've found a great post about how to set a port value: http://kinug.com/c4d/cpp/help/pages/c4d_graphview/doc_GVData699.html
However, if I add the method (GvSetPortGeData) and call it with: GvSetPortGeData(-1, myNode, mySecondInPort, run)); it seems to do nothing.
I have also tried this inside my new project, with the same result.
Before my call to GvSetPortGeData() I have the following code:GvPort* mathFirstInPort = mathNode->GetPort(1000); GvPort* mathSecondInPort = mathNode->GetPort(1001); GvRun* run = myNodeMaster->GetRun();
which comes after mathNode->SetParameter(GV_DYNAMIC_DATATYPE, ID_GV_DATA_TYPE_INTEGER, DESCFLAGS_SET_0);
If you need more information, just ask me.
Thanks in advance for your help and time!
Greetings,
Casimir Smets -
On 20/05/2015 at 10:00, xxxxxxxx wrote:
Hello,
could you please post all the relevant code of what you are doing and a precise description of what you want to do?
Best wishes,
Sebastian -
On 21/05/2015 at 02:02, xxxxxxxx wrote:
Hi,
What I try to do is simply add a math node, and set the following properties:
- The Datatype (Integer)
- The Math Function (Multiply)
- The second input port value (-1)Here is my full code (except the resource files).
#include "c4d.h" #include "c4d_symbols.h" #include "omyplugin.h" #include "main.h" #include "c4d_basedocument.h" #include "c4d_graphview.h" #include "gvmath.h" class MyPluginData : public ObjectData { INSTANCEOF(MyPluginData, ObjectData) public: virtual Bool Init(GeListNode* node); virtual Bool Message(GeListNode* node, Int32 type, void* data); static NodeData* Alloc(void) { return NewObjClear(MyPluginData); } }; 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 == nullptr) return false; GvDynamicData data; GvAllocDynamicData(node, data, info); CUSTOMDATATYPEPLUGIN* pl = FindCustomDataTypePlugin(data.info->data_handler->data_id); if (pl == nullptr) 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; GvFreeDynamicData(data); return true; } Bool MyPluginData::Message(GeListNode* node, Int32 type, void* data) { if (type == MSG_MENUPREPARE) { ((BaseObject* )node)->GetDataInstance()->SetInt32(PRIM_PLANE, PRIM_PLANE_XZ); } else if (type == MSG_DESCRIPTION_COMMAND) { DescriptionCommand* dc = (DescriptionCommand* )data; if (dc->id[0].id == CREATE_CHARACTER) { BaseObject* op = (BaseObject* )node; if (op) { XPressoTag* myXPressoTag = static_cast<XPressoTag*>(op->MakeTag(Texpresso, NULL)); if (!myXPressoTag) return false; GvNodeMaster* myNodeMaster = myXPressoTag->GetNodeMaster(); if (myNodeMaster) { GvNode* mathNode = myNodeMaster->CreateNode(myNodeMaster->GetRoot(), ID_OPERATOR_MATH); if (!mathNode) return false; mathNode->SetParameter(GV_DYNAMIC_DATATYPE, ID_GV_DATA_TYPE_INTEGER, DESCFLAGS_SET_0); mathNode->SetParameter(GV_MATH_FUNCTION_ID, GV_MUL_NODE_FUNCTION, DESCFLAGS_SET_0); GvPort* mathFirstInPort = mathNode->GetPort(1000); GvPort* mathSecondInPort = mathNode->GetPort(1001); GvRun* run = myNodeMaster->GetRun(); if (!GvSetPortGeData(-1, mathNode, mathSecondInPort, run)) return false; } else { return false; } } else { return false; } } } return true; } Bool MyPluginData::Init(GeListNode* node) { BaseObject* op = (BaseObject* )node; BaseContainer* data = op->GetDataInstance(); if (!data) return false; return true; } #define ID_MYPLUGIN 1000008 Bool RegisterMyPlugin(void) { return RegisterObjectPlugin(ID_MYPLUGIN, GeLoadString(IDS_MYPLUGIN), OBJECT_GENERATOR, MyPluginData::Alloc, "omyplugin", nullptr, 0); }
Thanks for your help and time!
Greetings,
Casimir Smets -
On 21/05/2015 at 07:37, xxxxxxxx wrote:
Hello,
when you debug your code you see that GetRun() returns a nullptr so GvSetPortGeData() cannot work. GvRun is only available during the calculation of Xpresso, so GvSetPortGeData() can only be used inside a custom Xpresso node while it is calculated.
But it seems using the correct DescID it is possible to simply use SetParamter() :
const DescID id = DescID(DescLevel(GV_MATH_INPUT,DTYPE_SUBCONTAINER,0),DescLevel(1001,DTYPE_LONG,0)); mathNode->SetParameter(id, Int32(-1), DESCFLAGS_SET_0);
best wishes,
Sebastian -
On 22/05/2015 at 01:18, xxxxxxxx wrote:
Hi,
Yes, that works!
Thank you very very much for your help and time!Greetings,
Casimir Smets