Hi,
I noticed a strange behaviour, no clue if it’s intended like that but it took me forever to find that mistake in my script and I wonder how to solve it without hardcoding something.
I get all kinds of parameter values from a list of elements and one of the lists starts without a value at index 0. The other lists also have no value somewhere in the list, but all of them have a value at index 0.
The strange thing that happens now is, when I import the list with no value at index 0 into a Python script-node it gets shorter than the other lists with a value at index 0. That ruins my for-loops…
When I use a string from array-node I get the same effect:
Is that a bug or why does it shorten the list if it starts without a value but doesn’t care for the value later on? Any solution how to solve it?
Thanks in advance 
Can you post a graph with the minimal python node to reproduce the error?
1 Like
Puh, it’s quite a long python code, with 8 other inputs… Not sure if that helps.
I just found that there is a value at index 0, if I list all indices with a string = “” it shows up:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# inputs that are necessary to determine the type of the door
width = IN[0]
height = IN[1]
family = IN[2]
construction = IN[3]
dicti = IN[4]
fire = IN[5]
acustics = IN[6]
beslag = IN[7]
ending = IN[8]
# dictionary with all doortypes
master = {}
# debug
errors = []
list_out = []
all_concat_name = []
# Place your code below this line
for i in range(len(width)):
# concatenate all types to create the later dictionary
concat_name = str(width[i]) + "-" + \
str(height[i]) + "-" + \
str(family[i]) + "-" + \
str(construction[i]) + "-" + \
str(fire[i]) + "-" + \
str(acustics[i]) + "-" + \
str(beslag[i])
all_concat_name.append(concat_name)
"""
if entry already exists, just add the element
"""
if concat_name in master.keys():
list_out.append(master[concat_name])
elif construction[i] not in dicti.keys(): # if the Construction Type is not named the element will end up on a "error-list"
errors.append(concat_name)
list_out.append("-")
pass
else: # otherwise it creates a new key with a unique number for the door type
existing_entries = [] # empty list of exisiting values
string = dicti[construction[i]] + str(width[i])[:-2] # the most basic string of the value, without ending (e.g. "GP10")
# gathering all values in the littera dictionary (e.g. GP10A, GP10B...)
all_values = master.values()
# compare if the value is in the list of all_values and append it to the list of existing_entries
for value in list(all_values):
if string in value:
existing_entries.append(value)
else:
pass
# if the existing_entries is empty (no similar doortype and width), it will create a whole new entry with "A" as first ending
if len(existing_entries) == 0:
# parse the value to the export
new_entry = string + "A"
else:
if len(existing_entries) > 1: # if the list has more than one entry it sorts the list and uses the last value of the the list to continue
# sort the list
existing_entries.sort()
# use the last entry of the sorted_list
existing_entry = existing_entries[-1]
# last letter of the existing_entry
last_letter = existing_entry[-1]
# increment the last letter
new_last_letter = chr(ord(last_letter)+1)
new_entry = string + new_last_letter
else: # otherwise it skips sorting and uses the only entry in the list, at index 0
existing_entry = existing_entries[0]
new_entry = string + chr(ord(existing_entry[-1])+1)
# the new entry is a concatenation of string (GP10) and the incremented ending of the last element in the list
master[concat_name] = new_entry
list_out.append(new_entry)
# Assign your output to the OUT variable.
OUT = [list_out,errors,master.values(),all_concat_name]
I tried to reproduce it, but now it’s not happening anymore… Sorry for the fuzz, no clue what made the difference.
1 Like
Likely your dynamo VM was in a bad state. Open and closing the graph, or open and closing Dynamo, or sometimes restarting your CPU will sometimes resolve these kinds of issues. 
2 Likes