Using My Blocks in VEXcode VR

My Blocks is one of the block categories within VEXcode VR. Some other categories include Magnet, Looks, Sensing, and Variables. My Blocks are used to create a sequence of blocks that can be used multiple times throughout a project.


How to Make a Block

My Blocks category selected in the Blocks palette

Select “Make a Block” from the My Blocks category.

My Blocks stack showing a custom block call in a VEXcode VR project

Rename the block by entering in the "Block Name" field, then select "OK."


How to Customize a Block

Add an input (number)

VEXcode VR workspace with a My Block definition and the custom block added to the project stack

Select the, “Add an Input (number)” option from the “Make a Block (Preview)” screen. Rename the input by entering in the “Number” field, then select “OK.”

Add an input (boolean)

My Blocks menu with the custom block “Drive in a square” available for use in VEXcode VR

Select the, “Add an Input (Boolean)” option from the “Make a Block (Preview)” screen. Rename the input by entering in the “Boolean” field, then select “OK.”

Add a label

My Blocks button used to create custom blocks in VEXcode VR

Select the, “Add a label” option from the “Make a Block (Preview)” screen. Rename the label by entering in the “Label Text” field, then select “OK.”

Combine inputs and labels

My Block with speed and distance inputs in the VEXcode VR block palette

Combine inputs and labels together in order to create a sequence of blocks.


How to Delete Inputs / Labels

Delete the selected input from the My Block settings menu

To delete an input or label, select the “Clear” icon on top of the input or label that you wish to remove.


How to Use the Define Block

VEXcode VR workspace with My Blocks organizing a custom sequence into reusable blocks

A parameter can now be used from the “Define” block once it is created.

Blocks showing a My Block definition with pen down, drive, and turn commands for the VR robot

Attach additional blocks to the “Define” block.

Adding a number block as an input to a My Block parameter in VEXcode VR

Use parameters from the “Define” block.

My Blocks palette with the custom Draw a Square block available for use

Use the “My Block” attached to the “When Started” block.


How to Use My Blocks

Drawing Squares Example

In this example, the robot will use My Blocks to:

  • Drive forward 200 mm
  • Draw a 300 mm square with the black pen
  • Turn right for 25 degrees
  • Draw a 500 mm square with the red pen

The “Define” hat block breaks down a procedure. In the following example, this “Define” hat block breaks down the blocks used to draw a square a certain number of times. Drag arguments from the define block to be used within the blocks.

Once the “Define” block is set, the newly created block can now be dragged and added to the “When Started” block to set parameters.

VEXcode VR project using a My Block to repeat commands for drawing two squares with the pen tool

Once the parameters are changed, the project is ready to be Started.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: