Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Shader Link null in MSG_DESCRIPTION_POSTSETPARAMET

 Post Reply Post Reply
Author
Message
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 300
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Topic: Shader Link null in MSG_DESCRIPTION_POSTSETPARAMET
    Posted: 2017 Jul 26 at 2:49am

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.



Edited by peterakos - 2017 Aug 03 at 1:59am
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Online
Posts: 366
Post Options Post Options   Quote gr4ph0s Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 26 at 6:09am
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 ForceGetLink
    case 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 (http://www.plugincafe.com/forum/forum_posts.asp?TID=13266)
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);
}


Edited by gr4ph0s - 2017 Jul 26 at 6:14am
Technical lover.
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 300
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 26 at 7:03am
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 !
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Online
Posts: 366
Post Options Post Options   Quote gr4ph0s Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 26 at 7:13am
But using ForceGetLink instead of GetLink didn't fixed the thing? (In my case it does)
Technical lover.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1497
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 27 at 9:32am
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?

Cheers,
Andreas
SDK Support Engineer
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 300
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 28 at 6:49am
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 !


Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1497
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 02 at 9:54am
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.

Cheers,
Andreas
SDK Support Engineer
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 300
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 03 at 1:58am
Hello Andreas and thank you very much for this information !
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 300
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 18 at 2:15am
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 !




Edited by peterakos - 2017 Aug 18 at 2:17am
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1497
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 18 at 9:19am
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.
Cheers,
Andreas
SDK Support Engineer
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1497
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 29 at 8:58am
Sorry for letting you wait.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.