I’m looking for someone who can help me make this line tool variation

I’m looking for a developer who can help me make the following variation on the line tool based on keypresses.

It’s to help me make room layouts from client plans (to speed up workflow).

I want the tool to draw a line based on pressing one of the cursor keys then inputting the length (and pressing enter).

Up Cursor = Draws a line along the green axis (positive value)
Down Cursor = Draws a line along the green axis (negative value)
RIght Cursor = Draws a line along the Red axis (Positive value)
Left Cursor = Draws a line along the Red axis (Negative value)

For example, to draw a square which is 1000mm x 1000mm:

Press ‘Up’ Cursor, then type 1000, press enter
Press ‘Right’ Cursor, then type 1000, press enter
Press ‘Down’ Cursor, then type 1000, press enter
Press 'Left; Cursor, then type 1000, press enter

And a square is born…

If anyone can help, paid or otherwise it would be marvellous…

So much faster than using the rectangle tool.
Start rectangle, type 1000,1000 hit enter, done.


Thanks for the advice, but you are missing the point, I don’t want to use the tool for making rectangles, that was just used for example of the input method I want to utilize. The tool is for creating rooms from architect and 2d plans provided from my clients. This is something I do on a daily basis and the tool is to help speed up my workflow.

Yes I can see how it would be useful but you didn’t give a good example.
Something like this would be better to get your idea across, to start in one corner and work your way around the room without taking your hands off the keyboard would be very nice.

I don’t think you’ll be able to use the arrow keys for this, they may be too locked in, but another set of keys, perhaps all you need is left and right. So after each input you hit left or right to tell it where to draw next.

1 Like

Yes that’s exactly it 100%. That image example is very typical of the floorplan I get from clients and you are right, the idea is to create it quickly without taking hands off the keyboard.
I did have feedback from Dan that using the cursor keys would be a violation of how Sketchup works but an alternative could be using shift with the cursors (or shift lock?) or otherwie assigning other keys would do it.
Ideally I would like someone to help me make this as its a little beyond my skill level, but otherwise I’ll just have to keep trying to do it myself when I have time…

This video shows the remapped arrows keys. They are remapped for x (Right and Left Arrows) and y (Up and Down arrows) axes.

The key strokes work for the first square, but not for the second. The difference is that I drew the square around the cursor for the first, but to the left and below for the second square. By ‘not working’, I mean that I had to input “-” in the VCB to change the direction that the line will be drawn in.

Using the keys in this way is more intuitive than the normal inference (Right and Left arrows).

It seems that inferencing uses the mouse_ip (that’s why the “-” is needed in the second example). To make the arrow keys work (irrespective of cursor location), it seems, the inference would have to ignore the cursor and reference the end point of the last line drawn. And, no, I don’t know how to do that :).

Thanks, that is sort half way there to what I need.
What did you mean by the arrow keys being remapped - how did you do that?

Sorry, I may have replied on the wrong thread. Dan pointed it out here: How to assign keyboard buttons within a script - Developers / Ruby API - SketchUp Community

What I mean is that I used the code from the ruby-api-tutorials/examples. sketchup-ruby-api-tutorials/examples at main · SketchUp/sketchup-ruby-api-tutorials (github.com)

I knew that there is a VCB example and an inference lock example there. So, I just found the “inference_lock_helper.rb” file, and ‘remapped’ the the buttons:

VK_LEFT, I changed to x axis.
VK_UP, I changed to y axis.

Then I added VK_Down and pointed the inference lock to y axis.

In this way the arrow keys are more like Left/Right and Forward/Backward.

It ‘works’ but you have to use “-”. Dan showed an example using .reverse. I’m going to presume that is what needs to be done to solve the problem. But I don’t know how to do that.

To remove potential problems with remapping the cursor keys (and without needing to add Shift), could you use the ‘old fashioned’ W A S D keys instead of the cursor keys?

Hello @john_mcclenahan, that seems like a good solution as well. But there is still the issue that the remapping that I did only puts the inference lock on either the x or y axes. The basic solution is still to enter “-” depending on line tool location.

It does seem that using “.reverse” could reverse the direction (vector) without needing to modify with “-”. I don’t know how to do that.

Another solution that might work would be to move the cursor to the end point of the line drawn. There is some code in a file (main.rb) from the examples I mentioned earlier that might be modifiable to help accomplish this. It seems that the mouse needs to be dragged a bit to make the tool active again after a line is inputted. That could be changed to “o” (I already changed it from 10 to 1 because I was curious). I will try 0. But then the cursor needs to be moved to the end point for this to work. I’ll try that now… yes, same thing (still need to modify with “-” depending on the location of the cursor).

Well, I’m interested to find out if moving the line tool (cursor) to the end point of the last line drawn would work… but it would take me some time to figure that out.

Do you know how to move the line tool to the end of last line drawn?

My Ruby skills were never great, and are now rusty from lack of recent use, so sadly my answer is ”no I don’t”.

But since your code drew the last line segment it knows where the last point was. And the next segment (usually, at least) has to start there, so even if you don’t put the cursor there, you can start a “rubber band line” from that point, drawn by the code in your tool…

@john_mcclenahan Ah. Just learning here.

I may be totally mistaken… I was just playing with the line tool and it occurs to me that it’s no longer a line inference tool if the cursor is either at the end point, or along the axis the cursor is on. It’s a ‘line direction tool’. I’ll show what I mean in a video.

You can see a couple of lines drawn with the inference arrows. Then, when the cursor is on the end point of a line it is not possible to enter a value in the VCB.

I’ve passed this onto someone who is a coder, I’m not, they may or may not come back with a solution.
But the way I see it.
The line tool can be set to continuous drawing but the mouse is needed to set the direction and then it will accept distance input.
the tool should be given a plane, whether x,y or z or a predrawn face
to start the tool click mouse to place start point, click mouse to set one edge and initial direction
tap arrow key to define next direction, left arrow perpendicular to the left, up arrow straight on, right arrow perpendicular to the right, down arrow back on itself (you might be able to get fancy and type a rotational deg)
type distance and hit enter
tap arrow, type distance hit enter
repeat until done.

So the arrow keys become axis agnostic, the line tool simply goes left, right, straight on or back, on the same plane and relative to the last edge. If they need to be the WASD keys, so be it.

I agree. The problem (with my example) is that the line direction inferences from the position of the line tool. That’s why I had hoped the inferencing would work with the line tool on the last point of the line.

I actually like how the tool works now. When I press the arrow key, if it inferences the wrong direction (because of the location of the line tool), I just type, “-” before the number. But to have it work without the inferencing -maybe with a little cursor indicating the selected direction… that’d be really useful.

Hopefully your friend will give it a try… and show us how it’s done!

1 Like

What is important for me is also the ability to keep going along in the same direction with separate measurements, ie. door and window placement in a floor plan.
Then offset and push pull can be used to make the walls and when extruded they will show vertical lines at the break points from which the doors and windows can be made (only the heights would need to be set - quick and easy to do with a guideline).

Yes, that’s why I suggested the up arrow as continue in same direction and down as back track. This way you aren’t trying to think red, green etc just left, right, keep going. etc


Very similar to what I want - now that would be a fun way to make floor plans :slight_smile:

s4u linetool
I try customize s4u Linetool for this case.

1 Like

Almost perfect. Just needs a longer snake.