That could be described as CSV data (Comma Separated Values,) as yes it is a very old way of separating data.
BUT, it has a drawback, especially in SketchUp inputboxes. Euro users often use the comma as a decimal separator, so for them they’ll use the semi-colon as a value separator.
So, you’ll need to determine what the value (list) separator is, and what the decimal separator is. The API added a submodule for this in SketchUp v2016M1:
if defined?(Sketchup::RegionalSettings)
LIST_SEPARATOR = Sketchup::RegionalSettings::list_separator
else
begin
"3,3mm".to_l
rescue
# comma not used for decimal separator:
LIST_SEPARATOR = ','
else
# No error, so comma is used for decimal separator:
LIST_SEPARATOR = ';'
end
end
Then, use standard String
class methods to split the string and strip the results.
input = "3@3m, 4m, 5m"
# or: input = "3@3m; 4m; 5m"
spacings = []
values = input.split(LIST_SEPARATOR)
values.each {|v|
if v.include?('@')
i = v.split('@')
num = i.first.strip.to_i
interval = i.last.strip.to_l
num.times do
spacings << interval
end
else
spacings << v.strip.to_l
end
}
Then, with the spacings
do a loop creating or copying the geometry:
model.start_operation("Spaced Geometry")
spacings.each {|interval|
# Call a method that uses the interval:
make_geometry(interval)
}
model.commit_operation
P.S. - I have no idea in which axis the interval will do it’s work (nor what the start point is,) … this is up to you.