Introduction: AutoCAD MacroMitt

About: IT Manager and CAD Designer with a keen interest in technology for the visually impaired.

In my work I use a small number of AutoCAD commands and keys repeatedly. These include:

  • OSNAP - toggles snapping to objects.
  • ORTHO - toggles orthogonal movement.
  • PICKSTYLE - toggles group and individual object selection (aka Group On / Group off)
  • CANCEL - pressing the Escape key
  • RETURN - pressing of the Return key

Some of these are tedious as they require a number of keystrokes, mouse clicks or require the removal of my hand from the mouse to press keys. I decided to design and build a solution that would address these problems.

This Instructable describes the design, construction and testing of a five key, one handed keyboard for these frequently used functions in AutoCAD.

Such dedicated keyboards are often called MacroPads because they send strings of characters (Macros) to a computer.

This keyboard has been designed to be used specifically with AutoCAD and has been shaped to allow the fingers and thumb of my left hand to rest on the keys comfortably. It is thus possible to press the desired key without having to look.

It resembles a mitten in shape hence the name MacroMitt.

The palm of the hand is placed on the MacroMitt to keep it firmly in place on the desk.

MacroMitt also features a rotary encoder that is used as a physical volume control. This control is also a button that can be clicked to Play / Pause media.

The keys and controls of MacroMitt could be reprogrammed for other AutoCAD commands or for other software including games.

Supplies

3D Printer - I use an Original Prusa i3 MK2 - no longer available but the current version can be found here: Prusa 3D

PLA Filament - I used black filament available here: Geeetech Black Filament

Arduino Micro - must be ATmega32U4 based to allow full USB communication with the PC: Arduino Micro

5 off Keyboard switches - I used Cherry MX Red keyboard switches: Cherry Keyboard Switches

5 off Cherry MX Relegendable Keycaps: Keycaps

1 off Rotary Encoder:Rotary Encoder

Knob for Rotary Encoder: I used a spare knob from my Prusa Printer kit similar to this: Knob

Stripboard: 64x95mm - Stripboard

6 off 3x12mm self tapping screws. I used ones from this set: Screws

1 off 2m Left Angle micro USB charging and data lead:USB Lead

1 off 2.5mm off grommet. I used one from this set: Grommets

4 off Self Adhesive Rubber Feet - from stock.

Step 1: Designing the Case

The buttons on the MacroMitt had to be positioned so the fingertips of my left hand rested comfortably on the keytops. I drew a line around my hand resting on a sheet of paper and measured initial dimensions.

I then transferred these dimensions to an AutoCAD drawing. This was then printed out at full size and the positions checked by resting my hand on the printout. Any adjustments were then made to the drawing.

This process was repeated several times until the button positions were satisfactory.

The final AutoCAD DWG file is attached, and a graphic version is shown in the picture.

Step 2: 3D Printing the Case

Using the drawing created in the previous step, a 3D model of the case was produced using Microsoft 3D Builder.

The case in in three parts: Top, Base and Cable Clamp - pictures 1 to 3.

The cable clamp could have been merged with the base but this would have required extensive support during printing.

The final picture is an exploded assembly view.

The three parts were printed in the orientations in the .3mf files using the following settings:

Top: 0.1mm Layer height, 20% infill, Support Material On

Bottom: 0.1mm Layer height, 20% infill, Support Material Off

Clamp: 0.05mm Layer height, 100% infill, Support Material Off

The clamp can be super glued into the slot in the base. Make sure the orientation of the clamp is correct with the semicircle cutout facing upwards - see assembly view.


Edit - 13th May 2023

I have been asked to provide a 3mf file with the elements ungrouped to allow easier modification. This file is attached below.

Step 3: Circuit Schematic

The circuit schematic diagram is shown in the picture and the attached PDF file. It is very simple consisting of the connections from the key switches and rotary encoder to the Arduino Micro Pro.

The circuit is powered through the USB cable that also carries the data to the PC.

A DWG version of the diagram is included in the next step.

Step 4: Circuit Board

The circuit board is shown in the picture and the attached PDF and DWG files.

Suggested construction order:

  1. Drill 4 mounting holes (3mm diameter).
  2. Cut copper strips where indicated - I use this tool: Brimal Cutter
  3. Solder the onboard blue and green wires into position. The colours are optional.
  4. Solder the header pins into position. I used header pin strips, removing the unwanted pins by pulling them out of the plastic strip with pliers. The remaining pins are then easier to solder into position as they are mechanically stable. It is advisable to remove the unwanted pins to allow wires to pass through neatly.
  5. Solder the Arduino Micro into position.

At this stage do not solder the external switch connections onto the header pins. This will be carried out when the board is mounted in the case.

Step 5: Assembly - Part 1

Note that the pictures show the key switches and rotary encoder in position. In fact these do not need to be fitted until the next step.

  1. Insert the USB connector into the Arduino Micro and route the wire as shown, snaking above and below the board mounting pillars. This helps to provide some pull protection.
  2. Cut the grommet on one side and push it over the USB cable and down into the slot in the case where the cable emerges.
  3. Carefully fit the circuit board onto the mounting pillars. Fix the board in place with two 3mm screws - do not overtighten or the PLA may break. The other two pillars have protruding pegs.

Step 6: Assembly - Part 2

Important: During this step be careful to keep the soldering iron tip away from the case as the PLA will melt and deform if heated.

The next step is to connect the key switches and rotary encoder to the circuit board pins.

I used single core insulated wire so that it could be bent into neat paths that would stay in shape.

Remove the key switches and encoder if they have been fitted. Solder suitable lengths of insulated wire to their pins (approx. 10cm). The colours are optional but recommended to make laying out clearer.

Starting with the thumb switch, feed the wire tails through the mounting hole and push the switch into position. Note that the switches fit best in one particular orientation with the 'tangs' to the sides.

Bend the tails into a neat path to the correct board pins. Strip the ends and wind each around the relevant pin. Solder the connection.

Repeat this process until the 5 switches are connected to the board.

Mount the rotary encoder using a washer and nut. The nut will have to be carefully tightened using small needle nose plyers (or a suitable socket driver). Connect the 5 tails to the correct pins.

Cut about 3mm off each of the 6 SPI header pins on the top surface of the Arduino (next to the reset button). This is necessary as the full height pins prevented the case base plate from being fixed in place.

Step 7: Assembly - Part 3

Fit the base into position, making sure that the grommet and cable are clamped correctly.

Screw in the 3 fixing screws - do not overtighten.

Affix the 4 rubber feet.

Step 8: Adding the Keytop Labels and Encoder Knob

The key tops used in this project have removable transparent covers. Good looking keytop labels can thus be created by printing out the required symbols, cutting them to size and placing them under the transparent covers.

The first picture shows the labels I created in using AutoCAD. The DWG and PDF files are attached.

When the PDF or DWG files are printed at A4 each label is the correct size - 14x14mm. I used a Brother HL3150 colour laser printer.

The final assembly step is to fit the rotary encoder knob. The knob I had in stock could be pushed down too far so it would not turn or allow the button action to operate. The solution was to 3D print a spacer to be inserted into the knob before pushing it onto the encoder. This is the smallest and quickest to print item I have ever produced! See picture 2.

The .3mf file is attached.

The third picture shows the completed MacroMitt with the keytop labels and encoder knob in place.

The next step is to add the Arduino code to make the MacroMitt functional.

Step 9: Code

The code is shown below and the Arduino .ino file is attached.

Three libraries are used:

The Libraries and full documentation can be found via the links.

The listing below includes comments to explain the operation of the code.

Notes:

The Main Loop polls the state of the key switches - if any are pressed the required actions are dealt with by functions at the end of the code.

The main loop also checks the state of the encoder and produces the required outputs (Volume Up, Volume Down and Media Play/Pause).


The strings of characters to be sent to the PC are included in the functions at the end of the listing:


Emulate Escape key press:

Keyboard.press(KEY_ESC);

Emulate F8 key press (ORTHO toggle):

Keyboard.press(KEY_F8);

Emulate F3 key press (OSNAP toggle):

Keyboard.press(KEY_F3);

Emulate Control-Shift-a combined key press (PICKSTYLE toggle):

Keyboard.press(KEY_LEFT_CTRL); 

Keyboard.press(KEY_LEFT_SHIFT);

Keyboard.press('a');

 Emulate Return key press:

Keyboard.press(KEY_RETURN);


To change to different functions, replace the line or lines with the desired key codes.

// Libraries


#include <HID-Project.h>  //  https://www.arduino.cc/reference/en/libraries/hid-project/
#include <OneButton.h>    //  https://www.arduino.cc/reference/en/libraries/onebutton/
#include <SimpleRotary.h> //  https://github.com/mprograms/SimpleRotary

// Encoder Pin A, Pin B, Button Pin
SimpleRotary rotary(3, 2, 6);

//setup buttons with OneButton
OneButton button1(
  4,          // Pin Number  ESCAPE
  true,       // Input is active LOW
  true        // Enable internal pull-up resistor
);
OneButton button2(
  8,          // Pin Number  ORTHO
  true,       // Input is active LOW
  true        // Enable internal pull -up resistor
);
OneButton button3(
  10,         // Pin Number  OSNAP
  true,       // Input is active LOW
  true        // Enable internal pull-up resistor
);
OneButton button4(
  11,         // Pin Number  PICKSTYLE TOGGLE
  true,       // Input is active LOW
  true        // Enable internal pull-up resistor
);
OneButton button5(
  12,         // Pin Number  THUMB
  true,       // Input is active LOW
  true        // Enable internal pull-up resistor
);


void setup() {
  button1.attachClick(button1click); // Set up button 1
  button2.attachClick(button2click); // Set up button 2
  button3.attachClick(button3click); // Set up button 3
  button4.attachClick(button4click); // Set up button 4
  button5.attachClick(button5click); // Set up button 5


  Serial.begin(9600);
  Keyboard.begin(); // Init keyboard emulation
  Consumer.begin(); // Initializes the media keyboard
}


void loop() {  //Start of main loop


  button1.tick(); // Read button states
  button2.tick();
  button3.tick();
  button4.tick();
  button5.tick();


  int rDir = rotary.rotate(); //Rotary encoder direction: 0=Stationary 1=Clockwise, 2=Anticlockwise
  int rBtn = rotary.push();   //Rotary 


  // Encoder- Check direction
  if ( rDir == 1  ) {
    // Clockwise
    Consumer.write(MEDIA_VOLUME_UP); //Increase  Volume
    Serial.print("Encoder turned clockwise");
    Serial.println();
  }
  if ( rDir == 2 ) {
    // Anticlockwise
    Consumer.write(MEDIA_VOLUME_DOWN); // Decrease Volume
    Serial.print("Encoder turned anticlockwise");
    Serial.println();
  }
  if ( rBtn == 1 ) {
    Serial.print("Encoder Button Push");
    Serial.println();
    Consumer.write(MEDIA_PLAY_PAUSE); // Play/Pause Toggle
  }
} // End of Main Loop


//FUNCTIONS


// This function will be called when button 1 (ESCAPE) is pressed.
void button1click() {
  Keyboard.press(KEY_ESC); //Emulate Escape key press
  Serial.print("Escape Key Push");
  Serial.println();
  delay(50);
  Keyboard.releaseAll();
}


// This function will be called when button 2 (ORTHO TOGGLE) is pressed.
void button2click() {
  Keyboard.press(KEY_F8); //Emulate F8 key press
  Serial.print("F8 Key Push");
  Serial.println();
  delay(50);
  Keyboard.releaseAll();
}


// This function will be called when button 3 (OSNAP TOGGLE) is pressed.
void button3click() {
  Keyboard.press(KEY_F3); //Emulate F3 key press
  Serial.print("F3 Key Push");
  Serial.println();
  delay(50);
  Keyboard.releaseAll();
}


// This function will be called when button 4 (PICKSTYLE TOGGLE) is pressed.
void button4click() {
  Keyboard.press(KEY_LEFT_CTRL);  //Emulate Control-Shift-a combined key press
  Keyboard.press(KEY_LEFT_SHIFT);
  Keyboard.press('a');
  Serial.print("CTRL-SHIFT-a Push");
  Serial.println();
  delay(50);
  Keyboard.releaseAll();
}


// This function will be called when button 5 (THUMB BUTTON) is pressed.
void button5click() {
  Keyboard.press(KEY_RETURN); //Emulate Return key press
  Serial.print("Return Key Push");  //Warning: Pressing the Thumb Button (Return) during debugging
                                    //can cause freezes as a carriage return is sent to the PC!
  Serial.println();
  delay(50);
  Keyboard.releaseAll();
}


Connect the MacroMitt to the PC using the USB cable.

Upload the code using the Arduino IDE or your favourite alternative.

Fire up AutoCAD and test the functioning of the MacroMitt.

If there are problems, the Serial Monitor in the Arduino IDE can be used to check the operation of the MacroMitt. Be aware, however, that as the MacroMitt is emulating keystrokes unexpected actions can occur while debugging! For example, I found that the thumb key caused the serial monitor to freeze.

Step 10: Final Thoughts

This has been a satisfying project and the MacroMitt has definitely increased my productivity while using AutoCAD.

Producing a hand shaped case was definitely the most challenging part. Perhaps someone could produce a parameterised version so that MacroMitts can be easily produced for different hand sizes and shapes?

The MacroMitt sits to the left of my workstation with the USB cable disappearing under the keyboard.

I am right-handed so my my MacroMitt had to be a left-handed version. Do left-handed people require a right-handed MacroMitt?

Which AutoCAD commands would you put in MacroMitt?

What other software would benefit from a MacroMitt?


I hope that you have found this Instructable interesting. I look forward to your feedback and seeing your versions of this project.

Electronics Contest

Runner Up in the
Electronics Contest