# Node Output & Design Script Output Inconsistent

**URL:** https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918
**Category:** DesignScript
**Created:** [July 7, 2021, 3:29pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918 "2021-07-07T15:29:31Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 7, 2021, 3:29pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/1 "2021-07-07T15:29:31Z")

</div>

I often work through more complex problems with codeblocks and then convert to DS once I have all the list levels figured out. Today I noticed that my converted DS wasn’t returning the same number of objects as the nodes. I finally narrowed it down to the last line, `RemoveItemAtIndex`. The first codeblock uses the `t1` variable as the list of indices. The second codeblock uses the full function for defining `t1`. Those are the only differences.

Why are the codeblocks returning different lists? I’m mostly just curious and making sure it’s not a bug. I can use the defined variable as a workaround for now (assuming that output is actually the correct one.) Unfortunately I’m using a pretty complex dataset so I’m not sure if I’ll be able to create a representative example, but I can try if it becomes necessary.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/54872381a89ebc943aad49c0f163159576ad2042.png)

---

<div class="post-metadata">

### Author: ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)
#### Post date: [July 7, 2021, 6:29pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/2 "2021-07-07T18:29:52Z")

</div>

Hi @Nick_Boyts

Have you tried using DS inside function? Below is an example:

> [@DesignScript Flatten not working in Function](https://forum.dynamobim.com/t/designscript-flatten-not-working-in-function/65881/2):
>
> Hi @Mepdot You where missing tab and you need to define your inputs as var: Here is the edited function: def CategoryFamily(in1: var[]..[],in2: var[]..[]) { element1 = Revit.Elements.Element.ElementType(in1); familyinstance1 = Revit.FamilyInstance.ByFamilyType(element1); family1 = Revit.FamilyInstance.GetFamily(familyinstance1); t3 = DSCore.List.Flatten(family1, -1); t4 = DSCore.List.UniqueItems(t3); t5 = DSCore.List.Count(t4); t6 = DSCore.List.AddItemToFront(in2,t4); t7 = …

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 7, 2021, 7:57pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/3 "2021-07-07T19:57:47Z")

</div>

@Kulkul, not sure if this is what you were getting at, but with both versions inside a function they still return different lists.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/6/a63ab9bb74befd876a47e92ae90ae4a12cb91cb1.png)

---

<div class="post-metadata">

### Author: ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)
#### Post date: [July 7, 2021, 9:31pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/4 "2021-07-07T21:31:29Z")

</div>

Hrm, that is odd behavior Nick … @Aparajit_Pratap any thoughts on this one?

---

<div class="post-metadata">

### Author: ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)
#### Post date: [July 8, 2021, 1:57am UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/5 "2021-07-08T01:57:45Z")

</div>

> [@Nick\_Boyts](#):
>
> If this is what you were getting at, but with both versions inside a function they still return different lists.

I haven’t tested. Could you drop here dyn file with nodes and rvt file to test?

---

<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 8, 2021, 3:50am UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/6 "2021-07-08T03:50:52Z")

</div>

> [@Nick\_Boyts](#):
>
> I’m mostly just curious and making sure it’s not a bug. I can use the defined variable as a workaround

I think it is a bug, have encountered variations of this in the past and have sorted it by defining a variable. Long dotted or nested statements sometimes seem to cause trouble.

> [@Nick\_Boyts](#):
>
> The first codeblock uses the `t1` variable as the list of indices. The second codeblock uses the full function for defining `t1` .

Have you tried enclosing the function in the second code block within parenthesis?

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 8, 2021, 1:03pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/7 "2021-07-08T13:03:51Z")

</div>

@Kulkul I’ll get a sample file drawn up and share that.

@Vikram_Subbaiah I have tried parenthesis and that actually made it worse. Ended up roughly doubling the output list.

---

<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 8, 2021, 1:08pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/8 "2021-07-08T13:08:29Z")

</div>

What type of data is T2?

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 8, 2021, 1:10pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/9 "2021-07-08T13:10:08Z")

</div>

T2 is a list of number ranges.

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 8, 2021, 2:50pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/10 "2021-07-08T14:50:50Z")

</div>

Example file and graph saved here.

> **[Nick Boyts sent you 3 items](https://www.dropbox.com/t/A4veLH2l3vYdo2XQ)**
>
> DesignScript Test + 2 more items

---

<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 8, 2021, 5:36pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/11 "2021-07-08T17:36:01Z")

</div>

Alternate Design Script. Hope this works for you

 ![DesignScript Test_2021-07-08_11-00-41](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/f/4f7b897bec874d296c6d7e40fcc8169b630795df.png)

```auto
pc1 = pc.Intersect(pc<1><2>);
in1 = 0..(List.Count(pc)-1);
pc2 = List.RemoveItemAtIndex(pc1<1><2>,in1<1>);

```

Combining the same in a line…  
`List.RemoveItemAtIndex(pc.Intersect(pc<1><2>)<1><2>,(0..(List.Count(pc)-1))<1>);`

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 8, 2021, 6:18pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/12 "2021-07-08T18:18:05Z")

</div>

I thought I had tried adjusting lacing but it must have been before I isolated the inconsistencies in the outputs.

The DS you posted has an extra level in it, but I can easily remove it with `List.Flatten`. However, trying to flatten it in the single line causes problems again.  
_Edit: Never mind. I missed the parenthesis around the number range when recreating the single line. Weird how that works here but not in my original code._

At this point I’m more just confirming that it is a bug. I can get everything else working.

---

<div class="post-metadata">

### Author: ![Aparajit\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Aparajit\_Pratap](https://forum.dynamobim.com/u/Aparajit_Pratap)
#### Post date: [July 14, 2021, 3:57pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/13 "2021-07-14T15:57:10Z")

</div>

@Nick_Boyts could you confirm how you created the first and second code blocks? Did you type out the code, or did you use node-to-code and if you did one vs. the other, which is the code block with the manually written code vs. the node-to-code codeblock?

---

<div class="post-metadata">

### Author: ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)
#### Post date: [July 14, 2021, 4:43pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/14 "2021-07-14T16:43:29Z")

</div>

I honestly can’t remember exactly how I got to these specific codeblocks. Initially I manually rewrote the nodes into a codeblock, but once I noticed the discrepancies I used Node-to-Code to reaffirm that I translated everything correctly. There were no differences between either version when I checked.

---

<div class="post-metadata">

### Author: ![Aparajit\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Aparajit\_Pratap](https://forum.dynamobim.com/u/Aparajit_Pratap)
#### Post date: [August 8, 2021, 7:42pm UTC](https://forum.dynamobim.com/t/node-output-design-script-output-inconsistent/65918/16 "2021-08-08T19:42:36Z")

</div>

Thank you @Nick_Boyts for pointing out this bug! This is a legacy issue that was found and fixed thanks to you and @dahlj! The fix should be available in 2.13 release!
