Shader Link null in MSG_DESCRIPTION_POSTSETPARAMET
-
On 26/07/2017 at 02:49, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R18
Platform: Windows ;
Language(s) : C++ ;---------
Hello.I have a TagData and in Message call of MSG_DESCRIPTION_POSTSETPARAMETER, I need to retrieve the BaseList2D* from the shader link parameter I've just set.
Here is how I get the link:
GeData parameter; if (node.GetParameter(DescLevel(paramID), parameter, DESCFLAGS_GET_0)) { BaseLink* link = parameter.GetBaseLink(); if (link) return link->GetLink(node.GetDocument(), 0); } return NULL;
Even though link is valid, link->GetLink returns NULL.
I set the shader with a bitmap.Thank you for your time.
-
On 26/07/2017 at 06:09, xxxxxxxx wrote:
The document returned is not valid(don't know why but it's seem to be the issue), or at least it is valid only when you explicitly use SetParameter.
Then instead use ForceGetLinkcase MSG_DESCRIPTION_POSTSETPARAMETER: { if (!node) return true; // get the changed id DescriptionPostSetValue* dpsv = static_cast<DescriptionPostSetValue*>(data); //2015 is the id of my shaderlink if ((*(dpsv->descid))[0].id == 2015) { GeData parameter; if (node->GetParameter(DescLevel(2015), parameter, DESCFLAGS_GET_0)) { BaseLink* link = parameter.GetBaseLink(); if (link) { BaseList2D* linkedShader = link->ForceGetLink(); if (linkedShader) GePrint(linkedShader->GetName()); } } } break; }
Note that you can also use SetDParameter wich I guess it's more cleaner (https://developers.maxon.net/forum/topic/9852/13266_setdparameter-or-message-postsetparameter)
Bool TestObj::SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags) { if (!node) return false; // 2015 is my shaderlink id if (id[0].id == 2015) { BaseDocument* doc = node->GetDocument(); if (!doc) return SUPER::SetDParameter(node, id, t_data, flags); BaseLink* link = t_data.GetBaseLink(); if (!link) return SUPER::SetDParameter(node, id, t_data, flags); BaseList2D* linkedShader = link->ForceGetLink(); if (linkedShader) GePrint(linkedShader->GetName()); } return SUPER::SetDParameter(node, id, t_data, flags); }
-
On 26/07/2017 at 07:03, xxxxxxxx wrote:
Hello and thank you for your help.
I get the document from GeListNode* node parameter of message node->GetDocument(). It's the same as GetActiveDocument. Also, I cant use SetDParameter in my case for many reasons (hard to explain now). I need to do it in MSG_DESCRIPTION_POSTSETPARAMETER.
Thank you again !
-
On 26/07/2017 at 07:13, xxxxxxxx wrote:
But using ForceGetLink instead of GetLink didn't fixed the thing? (In my case it does)
-
On 27/07/2017 at 09:32, xxxxxxxx wrote:
Hi,
if ForceGetLink() changes anything opposed to GetLink() this is a strong hint that the entity pointed to by the link is either in another document or not part of a document at all.
As we are talking about links to shaders, are the shaders properly part of the document? -
On 28/07/2017 at 06:49, xxxxxxxx wrote:
Hello.
@gr4ph0s, ForceGetLink returns a valid link.
@Andreas, the shaders are bitmaps that I have created by clicking the shader in Cinema 4D Attribute Manager of my TagData interface.Thank you for your time !
-
On 02/08/2017 at 09:54, xxxxxxxx wrote:
Hi,
sorry, this took a bit longer to figure out. Again, Sebastian contributed the idea.
In short, use ForceGetLink() in that message.
The reason is the order of events. While the TexBoxCustomGui indeed automatically inserts the shader into the scene (InsertShader() on the tag actually), the MSG_DESCRIPTION_POSTSETPARAMETER gets sent before the actual insertion. Test it with later messages, there GetLink() will work as expected.
In conclusion, peterakos you are doing everything correct. Sorry, for the inconvenience caused. We will check, where this information can be documented best.
-
On 03/08/2017 at 01:58, xxxxxxxx wrote:
Hello Andreas and thank you very much for this information !
-
On 18/08/2017 at 02:15, xxxxxxxx wrote:
Hello again.
Sadly, GetForceLink still generates some issues.
If I use GetDocument to the returned BaseList2D, I get Null as result.
Also, if the BaseList2D is an Xbitmap shader, the parameter BITMAPSHADER_FILENAME has no value.So, even though GetForceLink does return a valid pointer, I cannot use it.
Is there anything else I can do other than trying to access the shader in MSG_DESCRIPTION_POSTSETPARAMETER using GetForceLink ?Since the purpose of this question might be lost till now, what I want to do is to set a shaderlink parameter with a shader and retrieve that shader in its valid state. I have tried accessing it in SetDParameter and in MSG_DESCRIPTION_POSTSETPARAMETER message. It appears though, it's not "late" enough to access it.
Thank you for your time !
-
On 18/08/2017 at 09:19, xxxxxxxx wrote:
GetDocument() returning nullptr on the BaseList2D returned by GetForceLink() is to be expected, as it's the reason for the need to call GetForceLink(), it is not yet part of a document.
I'm sorry, I didn't realize the consequences for what you actually try to achieve. I will need to investigate and will get back to you.
-
On 29/08/2017 at 08:58, xxxxxxxx wrote:
Sorry for letting you wait.
MSG_DESCRIPTION_CHECKUPDATE (DescriptionCheckUpdate) should do the trick.