Variable Space Between lines


TIG, it all about his odd input field, that takes spacings.

It is not two objects spaced 10m apart, it is 2 objects spaced at 5m intervals, from a common start point that might also have a 1st object. (Think fence posts, here.)

But then using the “odd” input defeats the automatic unit conversion of the inputboxs.

At this point @vanlion, I’d suggest switching to a list of spacings like:

It’s just too strange for the user interface with those embedded (x) multipliers.



prompts = [‘Width’, ‘Height’, ‘Spacing’]




prompts = ['Number:', 'Width:', 'Number:', 'Height:']
defaults = [2,, 2,]
input = inputbox( prompts, defaults, 'Title' )
return unless input # e.g. user cancels so it's 'nil'
w_number, width, h_number, height = input

Then check the 4 values for being suitable - e.g. not <=0 etc…


Hi Tig,

Reasson that i can’t use variable spaces in your example. That was the reasson for the odd way i’m using seen in a YouTube video (first post).

My first basic idea was to greate the same layout used in the Revit grid generator (see pic) maybe things are clearer now?


But the Revit GUI has separate inputs for the Axis Spacing and the Number of Spacings - Horizontal and Vertical.
You could make a ‘webdialog/htmldialog’ which would mimic the Revit interface almost exactly.
You cannot do it in a simple input dialog - unless [as you have unsuccessfully tried] you input the ‘pairs’ of values with a separator etc.
Here is my ‘improvement’ of your code, keeping one entry per H/V orientation:
The user must know that the input is in the form 2x1234 or 2x1234mm
Just adjust the initial defaults, title, reference naming etc as you desire…

@horiz="2x5000" unless @horiz
@verti="2x2000" unless @verti
# this reuses the last entered values this session
prompts=["Horizontal: Number x Spacing ", "Vertical: Number x Spacing "]
values=[@horiz, @verti]
input=inputbox(prompts, values, "My Grids")
return nil unless input
return nil unless input[0]=~/x/ && input[1]=~/x/
# i.e. it's splitable at the 'x'
@horiz, @verti = input
horiz_number, horiz_spacing =' ', '').split('x')
verti_number, verti_spacing =' ', '').split('x')
# note how the 'tr' strips out any spaces that might mistakenly surround the 'x'
# now change these values into an integer and a length...
horiz_number = horiz_number.to_i
horiz_spacing = horiz_spacing.to_l
verti_number = verti_number.to_i
verti_spacing = verti_spacing.to_l
# Now you have those 4 references correctly formatted...


Thanks Tig,

I can make a webdialog that way so i can fix that.

but the only thing i wonder is when you have a webdialog ready, how to collect the data like the Revit example into spacings for example the horizontal spacings and numbers as you can see in the picture. You have a rule 5000 2 times, 6000 3 times and 1 time 4000. So you can use the spacings and interval in the code Dan gave me? Underneath you saw how we collect the spacings

spacings = []
values = input.split(LIST_SEPARATOR)
values.each {|v|
  if v.include?('x')
    i = v.split('x')
    num = i.first.strip.to_i
    interval = i.last.strip.to_l
    num.times do
      spacings << interval
    spacings << v.strip.to_l


@vanlion, One of the best ways to learn SketchUp coding is to read how others have done things.

FYI, The SketchUp Team has an example extension for interactively drawing construction grids: