In the new 3.5 SDK there are new functions under URCapProgramNode called canGetAs and getAs.
I tried using the canGetAs function on my newly created node to cast to the node’s service, contribution, as well as to a custom interface, that I created, that is implemented by the node’s contribution.and service. Every time it returns false. In the new sdk package there is no sample program on how to use this. Can you please show an example of how to use this functionality?
I have the same problem it only returns false, what is the correct way of implementing this?
I also found that canGetAs always returned false. However, getAs(MyCustomInterface) seems to work, and I can then cast this to a Contribution class to call whatever methods I want. You obviously need to put this in a try-catch block since getAs(MyCustomInterface) will throw an exception for nodes that don’t implement the interface.
have you ever tried to save the program with this node and then load the program? when it creates again the Tree after loading, I get a TreeStructureException, message “Parent node not in a tree.” when I call the GetAs:
…even if the node is created on the Tree, my returned Interface is
I’ve no problem loading other Nodes in the Tree, so I cannot understand why I get the exception.
Thank you, regards,
Matteo Timossi @recognitionrobotics