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: [5.m,5.m,6.m,4.m,5.m]
It’s just too strange for the user interface with those embedded (x) multipliers.
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 = @horiz.tr(' ', '').split('x')
verti_number, verti_spacing = @verti.tr(' ', '').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...
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