I am working on an IFC import, from a certain type of element I need to get the names, but only the ones of a text length of 49 characters. How can i split this list based on text length?
you can use a component called (list length) to identify the number of characters for each text then use (member index) and insert (49) to member input, then insert the final list to list item.
1 Like
Using @seltzdesign’s definition as a base, here is another option using Python:
import ghpythonlib.treehelpers as th
splti = []
for i,j in enumerate(x):
if len(j) == 49:
splti.append(i)
splti.append(len(x))
l1 = list(splti)
l1.pop(-1)
l2 = list(splti)
l2.pop(0)
a = th.list_to_tree([x[i:j] for i,j in zip(l1,l2)])
If you are looking for something specific in the IFC text, you could also do something like:
if "IFCSHAPEREPRESENTATION" in j:
Rather than looking for the string length.