Dynamic box with divisions

I have a simple box as a dynamic component with a user selection for how many divisions it should have. Then the division is copied this many times and spaced appropriately inside the larger box, no problem.

Now I would much rather have the user type in a “layout” or what you’d call it. Like typing “10,5” would create a 15cm long box with one division, one part being 10cm and the next 5cm.

In order to do this I would want to split the input “10,5” into parts, like [“10”, “5”] and then create copies on number of items in this split. But SketchUp doesn’t seem to support text splitting. and find() only finds the first occurance.

Any ideas?

Not sure if you want a Ruby fix here or a DC formula fix? It would also help if you could post the model?

I would create a series of attributes exposed to the user that get totalled for a full length, and drop divisions at their specified intervals. Use an IF statement to filter out the ones that are blank or 0.

this can be done using a series of attributes, I place a ready-made set in a scaler / swatch which I usually hide, then refence that, saves having to rebuild the code again

There is an example here

How to create a trapezoidal dynamic furniture - SketchUp / Dynamic Components - SketchUp Community

you find the position of each based on the position of the last search
pos1 = find(“,” , code, 1)
pos2 = find(“,” , code, pos1)
…posN = find(“,” , code, pos(N-1))

where code is the value you entered plus some amount of safety to stop an error return if find fails

code = input & rept(“,0” , 10) woud allow for 10 searches even though input = 315 (one value)

you split the code using

val1=mid(code, 1,pos1-1)
val2=mid(code, pos1+1,pos2-pos1-1)
…valN=mid(code, pos(N-1)1,posN-pos(N-1)-1)

you can check if within the original string


1 Like