# How to create a Range with Multiple Step values?

**URL:** <https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629>\
**Category:** Geometry\
**Tags:** dynamo, civil3d\
**Created:** [July 5, 2020, 9:41pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629 "2020-07-05T21:41:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 5, 2020, 9:41pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/1 "2020-07-05T21:41:18Z")

</div>

Hello everyone,

I have a small problem in the logic of my script. I want to split a line by distance in my script.  
For example every 3 meters the curve, then every other 3 meters and so on).

The catch however, is the fact that these 2 numbers (3 & 3) are input values, so they can be whatever number i need. So 1 & 3 and 3 & 9 are also inputs which should work.

I was thinking about using a code block with something like this, but i couldn’t figure out how to use multiple distances:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/b/8b839a9afc9427f093efd614aa103f3a30519f16.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/2/127aea02ae80592b35a577c7c427272db3b7a68c.png)

Thanks in advance!

- Daan

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [July 6, 2020, 5:37am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/2 "2020-07-06T05:37:20Z")

</div>

Hi @Daan,  
Something like this?

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/c/6cb0637dd47ee5538bd15948c2429e87d5b7c09d.png)  
[DoubleStepSequence.dyn](https://forum.dynamobim.com/uploads/short-url/2LR0nWbM063NXYug8EYXq4rUy4N.dyn) (9.2 KB)

**Option - 1**

```
sumNums = IN[2] + IN[3]
start = IN[0]
sum = start
rangeList = [start]

x = IN[3]

while sum < IN[1]:
	x = sumNums - x
	sum = sum + x
	if sum < IN[1]:
		rangeList.append(sum)

OUT = rangeList

```

**Option - 2**

```
inputs = IN[0].split("..")

def num(s):
    try:
        return int(s)
    except ValueError:
        return float(s)

sumNums = num(inputs[2]) + num(inputs[3])
start = num(inputs[0])
sum = start
rangeList = [start]

x = num(inputs[3])

while sum < num(inputs[1]):
	x = sumNums - x
	sum = sum + x
	if sum < num(inputs[1]):
		rangeList.append(sum)

OUT = rangeList
```

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [July 6, 2020, 6:09am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/3 "2020-07-06T06:09:47Z")

</div>

![dashed_2020-07-06_11-36-24](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/1/f1c2cab4608b2f730a4d583929436e9321a8d65e.png)  
[dashed.dyn](https://forum.dynamobim.com/uploads/short-url/A8KL8JZO9Ndhx7sJOWltqTr9XGD.dyn) (15.9 KB)

Or a line of Design Script  
`List.Transpose([0..#c..(a+b),a..#c..(a+b)]);`  
 ![dashed_2020-07-06_11-37-02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d6588ee0a3949af2e2b6280a19fd157c31309630.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 6, 2020, 11:09am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/4 "2020-07-06T11:09:05Z")

</div>

@Vikram_Subbaiah & @AmolShah

Thank you very much for both solutions!  
I will try both out and see which ones work best for me!

Thanks again!!

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 6, 2020, 11:21am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/5 "2020-07-06T11:21:56Z")

</div>

@Vikram_Subbaiah & @AmolShah

First of all, both solutions work great if i have a single input, but the problem is that it is almost always possible that i have multiple curves which need to be split like this.

This is what i have so far, maybe you guys know how to improve this 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/9/89a2935fc79ba102d6dc2d8c4a77da743be5bf93.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 6, 2020, 12:00pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/6 "2020-07-06T12:00:06Z")

</div>

Try making it a custom node. 🙂

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 6, 2020, 12:18pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/7 "2020-07-06T12:18:26Z")

</div>

A Custom Node? How would i approach that/ use that?  
(I have never made a custom node btw)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [July 6, 2020, 12:24pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/8 "2020-07-06T12:24:39Z")

</div>

> [@Daan](#):
>
> i have multiple curves which need to be split

 ![dashed2_2020-07-06_05-51-50](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/8/e84773db2435a4923ba09b98dbd4ceb552590681.png)

`List.Transpose(List.Transpose([0..#(lgt/(lin+gap))..(lin+gap),lin..#(lgt/(lin+gap))..(lin+gap)])<1>);`

[dashed2.dyn](https://forum.dynamobim.com/uploads/short-url/t2nwjDMYmfTsSg24neGknnDlPUK.dyn) (11.2 KB)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 6, 2020, 12:38pm UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/9 "2020-07-06T12:38:57Z")

</div>

This will help with that: [Custom Nodes | The Dynamo Primer](https://www.dynamoprimer.com/10_Custom-Nodes/10_Custom-Nodes.html)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 10, 2020, 10:11am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/10 "2020-07-10T10:11:39Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/0/c052b718ba868fe81baea725bdc648447b7c85ff.png)

Hey Vikram, my solution wasn’t fully working for me because i need to start at “line” instead of gap, but when i try to use your method, the last line gets cut of, but it could still fit.

Also i need the line to be created, even if the line is not the full length (example, if 1 meter line doesnt fit, but 0.5 does, use 0.5 as length for the last line.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [July 10, 2020, 10:46am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/11 "2020-07-10T10:46:17Z")

</div>

> [@Daan](#):
>
> i need the line to be created, even if the line is not the full length

The definition below should address that, but it could sometimes try to create a line of 0 length at the end. You’ll need to extend and improve the definition to eliminate such issues

 ![dashed3_2020-07-10_04-12-56](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/8/48c3981edf1a7c6fe53613aa4d311243b85189a7.png)  
[dashed3.dyn](https://forum.dynamobim.com/uploads/short-url/1ih9Z0yHmvKIy5hCogn5KbooYLA.dyn) (11.2 KB)

`List.Transpose(List.Transpose([0..lgt..(lin+gap),List.AddItemToEnd(lgt<1>,(lin..lgt..(lin+gap))<1>)])<1>);`

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [December 11, 2020, 7:44am UTC](https://forum.dynamobim.com/t/how-to-create-a-range-with-multiple-step-values/52629/13 "2020-12-11T07:44:15Z")

</div>

Small update: i now know how to create custom nodes 🙂  
I used your first Python script inside a custom node and it works perfect !
