I’m trying to edit a list of strings with a python script. It works in python but not in dynamo.
Code:
# 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
# Place your code below this line
oldlist = IN[0]
newfamilylist=[]
def returnfamily_string(family):
x = "Family:"
if x in family:
string1 = family.split(x, 1)[1]
return(string1.split(" ", 1)[1])
for y in oldlist:
newfamilylist.append(returnfamily_string(y))
# Assign your output to the OUT variable.
OUT = newfamilylist
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
elems = IN[0]
lists = []
for i in elems:
rvtFileName = i.Name.split(":")[0]
lists.append([i,rvtFileName])
OUT = lists
oldlist2=[]
for i in IN[0]:
oldlist2.append(str(i))
newfamilylist=[]
def returnfamily_string(family):
x = "Family:"
if x in family:
string1 = family.split(x, 1)[1]
return(string1.split(" ", 1)[1])
for y in oldlist2:
newfamilylist.append(returnfamily_string(y))
# Assign your output to the OUT variable.
OUT = newfamilylist