Probems with setting a new renderer and changing its settings at the same time

Been having some problem trying to set the renderer to vray and applying settings in the same script.
i got some code that checks for the existence of the vray plugin and sets the default renderer to vray if it exists, which is than followed by some code that gets the “vraySettings” node and starts setting attributes on it.

if the renderer is not set to vray before the script is run, PyNode fails to find the vraySettings node but if vray is set before hand i have no issue.

I tried to run my code for setting attributes using pymels evalDeferred but this dones not help at all.

Anyone had this issue before.

Was able to fix the issue,
Just tossed the search for it into a try and except, and Manually create the node if i get a MayaNodeError. If i create the node with the same name maya dosnt seem to care, and will use it for the renderSettings