One way to access an object in script is to find an object via its unique ID. Simmetri can generate the snippet of code necessary to do this if you drag and drop an object thumbnail from either the Browser panel or the Property Editor panel onto the Script editor window.
Once we have a variable to the object we want to access, we can query and set values on it. For instance, in the following script we access the
SkySpace = findObjectByUid("^1/14WA1O27OBRZY3805NLB9767IZ") -- Now we can access the SkySpace and its members directly: t = hours(16) + minutes(30) SkySpace.timeOfDay = t:toHours() -- timeOfDay expects an hour value [0,24]
- While this technique makes it easy to get a hold of objects in script, be aware that the unique ID means that if you duplicate the code to re-purpose it, you need to re-drag and drop objects to reassign their find ID.
- For more robust code, you can use other methods of finding objects as outlined in the following articles.