Spawning Objects In A Square

My problem is a bit hard to explain, which makes it difficult to search for a solution to.

I want to click at location A to define one corner of a room, then click at location B to define the opposite corner, and have boxes spawn in a grid using the two points.

I already have a blueprint which spawns a building made up of small squares creating the roof and outer walls when the game starts by attaching the roof actors to eachother in a loop and adding them to an array. I can also place a single box anywhere within this building to create a 1x1 room there, which will create walls around itself using line traces, if there is any roof next to it.

This is the building within which the player can build rooms. The small room inside was built in-game one square at a time. I’ve selected a few roof and wall actors to show them better.

This is the bit of the blueprint which spawns the bottom row of roof tiles, from right to left, until it reaches 50 tiles. It then continues to the next loop which spawns tiles in a column, and then another which fills out the rest.

I think the same system could be used to spawn a room between point A and point B, but I’m not quite sure how to go about it. If the player clicks point A, then moves the cursor to the right, boxes should spawn between A and the cursor, and if the player moves the cursor up, boxes should spawn from that bottom row of boxes and upward to the cursor, creating a square of boxes to form the room. Once the player left-clicks again, the boxes would be placed (that part I’ve already got figured out). I’ve got a snap to grid function in place as well. I guess what I’m lacking is a good way to track point A and the cursor.

108467-squaregrid.png

Something like this.

Short version (TL;DR)

Basically, player left-clicks at A, spawning a box actor there. Player then moves the cursor 200 units to the right. I need to get that distance in order to spawn a row of boxes along it. Player then moves the cursor 200 units up. I need that distance also in order to spawn boxes up to that point, creating a square of boxes.
How do I get the X and Y distance separately between point A and the cursor?

I managed to figure out a solution. Using a line trace for cursor’s location, I saved its X and Y values in floats called StartX and StartY when clicking location A, and the same for location B, as EndX and EndY. Then I took StartX minus EndX and divided the result with the size of my grid and truncated that value to get the number of boxes that would make up that distance.