I’m having trouble running a Python script for a list.
The script works perfectly for a single string.
I searched for a solution on this forum but couldn’t solve the problem yet, probably because it’s my first Python code and I don’t have any basics in programming .
The script converts a binary code into text.
Enable Python support and load DesignScript library
from Autodesk.DesignScript.Geometry import *
The inputs to this node will be stored as a list in the IN variables.
a_binary_string = IN
#Split into blocks of 8
n = 8
binary_values = [a_binary_string[index : index + n] for index in range(0, len(a_binary_string), n)]
#Convert to base 2 decimal integer
ascii_string = “”
for binary_value in binary_values:
an_integer = int(binary_value, 2)
#Convert to ASCII character
ascii_character = chr(an_integer)
#Append character to
ascii_string += ascii_character
Assign your output to the OUT variable.
OUT = ascii_string
I think the problem is in splitting the input in a sublist of 8 character blocks.
Could someone tell me how to run this code for each instance of the list, or even better, give me the working script and explain it to me?