Skip to main content

Lesson 2: Creating Projects in VEXcode VR Python

image of VEXcode VR Python in a new text project

Now it is time to get started with VEXcode VR Python and the VR Robot! With VEXcode VR Python, you can program a VR Robot to do many things. This lesson will show you how to get started programming with VEXcode VR Python.

Learning Outcomes

  • Identify how to add, move, and delete commands in a project.
  • Identify how to run a project in VEXcode VR Python.
  • Identify how to load, rename, and save a project.
  • Identify how to open an example project.

Building a New VEXcode VR Python Project

Every VEXcode VR Python project begins by defining the main function, and uses a comment and a def main function to identify where your project should begin. image of a new text project in the workspace with the main function highlighted

Each new Text project has a default Drivetrain command added. When you build your project, your first command will replace this one. image of the default drivetrain command in a new text project

Adding, Moving, and Deleting Commands

There are several ways to add commands to a VEXcode VR Python project.

  • You can select a command in the Toolbox and drag and drop it into a project. In the Workspace, the command will be colorized. (You will learn more about the colorization of commands later in this Unit.) To edit a command or its parameters, type directly in the Workspace. This video clip will show you how to add a command to a project, and adjust the parameters. 
    Video file
  • You can also type commands directly into the Workspace. As you type commands in the Workspace, they will be automatically colorized.

    • To add a command in the desired location, use the cursor or press 'Enter'/'Return' on the keyboard at the end of a row to move to the next row. To indent commands, press 'Tab' on the keyboard. Notice that as you type, the auto-complete feature will populate command options for you.

    • This video clip will show you how to type commands into a project. The first command will be typed completely, and the second command will be added using the auto-complete feature. To learn more about using the auto-complete feature in VEXcode VR Python, see this STEM Library article.

    Video file
  • Once commands are added to a project, they can also be copied and pasted using keyboard commands or the Context Menu in VEXcode VR Python.

    • To copy a command or sequence of commands, select the command and right click or long press to open the Context Menu. Then select 'Copy'. 

    • To paste, place your cursor in the desired location in the project, and right click or long press to open the Context Menu. Then select 'Paste'. Your commands will now be added to the project. 

    • This video clip will show you how to use the Context Menu to copy and paste commands in a project. 

      Video file
  • The Context Menu can also be used to move, or reorder, commands in a project.
    • To move command(s) within a project, first use your cursor and the 'Enter'/'Return' button on the keyboard to create a space in the project in the desired location.
    • Then select the command(s) that you wish to move, and right click or long press to open the Context Menu. Select 'Cut'.
    • To move the command(s), place your cursor in the open space you created, and right click or long press to open the Context Menu. Then select 'paste'. Now your project is reordered. 
    • This video clip will show you how to reorder commands using cut and paste in the Context Menu. 
      Video file
  • To delete a command, select the command and press 'Delete'/'Backspace' on your keyboard, or use the Context Menu and select 'Cut'. When a command is deleted, an empty space will appear. Extra spaces between commands may not prevent your project from running, but can be eliminated if desired. To consolidate your project, use the cursor or arrow buttons, and the 'Delete'/'Backspace' button on the keyboard to move subsequent lines of the project up to the desired location. This video will show you how to delete a command and consolidate the project. 
    Video file

Starting a Project

Once you are ready to try your project with the VR Robot, you can do so. Select 'Playground' in the Toolbar. Then select 'Start', beside the Playground button. The VR Robot will now run your project. This video clip will show you how to open the Playground Window, and start a project. 

Video file

Note: You can change the VEXcode VR Playground using the dropdown menu in the Playground Window. 

To learn more about starting and stopping and project in VEXcode VR Python, see this STEM Library article.

Renaming, Saving, and Opening a Project

In VEXcode VR Python, all projects begin with a default name of “VEXcode Project”. To rename your project, select the project name box and type your desired project name. Then select 'Rename'. This video clip will show you how to rename a project. 

Video file

When you are done coding, you can download a copy of your project. Select 'File' in the Toolbar, then select 'Save to Your Device'. image of the save to your device selection in the file menu

To open a saved project from your device, select 'File' in the Toolbar. Then select 'Load from Your Device'. image of the load from your device option in the File Menu

Opening an Example Project 

Example projects are a great place to learn about commands and behaviors. 

  • To open an example project, select 'File' in the Toolbar. Then select 'Open Examples'. 
  • Select the example project you wish to open.
  • If you have an unsaved project open in the Workspace, you will be prompted to discard or save it. Once that selection is made, the example project will open in the Workspace. 
  • This video clip will show you how to open an example project, by discarding the existing project in the Workspace. 
    Video file

You can now start the example project to observe the behaviors, and then edit the example project as you would a new Text project.