Writing Your First ARDI Script
Let's look a very common command - perspective.
The command is used to move the camera to look at a given asset.
Using the documentation (in the link above), we find that perspective has a number of parameters. The most important is target, which is the name of the asset we would like to focus on.
So imagining we have a scene that contains an asset called 'Main Engine', we could have the following command…
<script> <perspective target="Main Engine"/> </script>
This script will take control of the camera, move so that the Main Engine is visible, then end.
Running Local Scripts
To run a local script, look in your Documents folder. You should find a folder named Optrix/ARDI/<database-name>Scripts (for example, if your database is called “Headquarters”, it would be under Optrix/ARDI/Headquarters/Scripts)
Save the XML file to this folder.
When you press F11 in ARDI-VE, you'll be prompted to choose from the available scripts. Scroll down to find the name of the file, then click it.
Adding More Steps & Sequencing
One of the keys to writing ARDI scripts is understanding the control functions. These control how your scripts move from one step to the next.
Normally, ARDI immediately moves from step-to-step. It doesn't wait for the previous step to complete before proceeding. This means that if you're performing a long-running task that you'd like the user to see, you need to interrupt the flow of steps.
Function | Purpose |
---|---|
block | Wait until all running functions have stopped |
pause | Wait a given amount of time (default=1s) |
waitforclick | Wait until the user clicks the 'Next' button. An on-screen caption is optional |
So if we wanted to intoroduce someone to several components - the Main Engine, Secondary Engine, we could have the following script…
<script> <!-- Show the Main Engine--> <perspective target="Main Engine"/> <waitforclick caption="This is the main engine"/> <!-- Show the Secondary Engine--> <perspective target="Secondary Engine"/> <waitforclick caption="This is the secondary engine"/> </script>
Introducing Other Functions
Now the main engine is made up of dozens of parts, and we'd like to highlight some of those components.
You can access sub-components of assets by using a path.
For example, in this case we are going to highlight the exhaust on our main engine as part of our scripted tour.
<script> <perspective target="Main Engine"/> <waitforclick caption="This is the main engine"/> <!-- Show the Main Engine Exhaust, and remove the highlight when you're done --> <highlight target="Main Engine\*Exhaust"/> <waitforclick caption="This is the main engine"/> <unhighlight target="Main Engine\*Exhaust"/> <perspective target="Secondary Engine"/> <waitforclick caption="This is the secondary engine"/> </script>
Exhaust is a component inside the Main Engine 3D model. By using the asterisk (*), we tell ARDI that we don't care where exactly the 'exhaust' object is, just that it must be somewhere under the Main Engine.
The highlight step shown above is an example of a step that needs to be removed when you're done. Unhighlight performs this job.
When a script terminates, it is cleaned up. This means that many behaviours - such as the Highlight shown above - will automatically be reversed when the script completes.