Converting strings from excel to lines

First of all, thanks for all the help you guys already gave me, I am new to Dynamo but learning!
I am trying to use some lines that i imported from excel, but it seens that dynamo is reading it as strings, how do I convert strings to lines?


See if this helps? Working with Strings in Dynamo is always a bit long winded, you could probably be a lot more compact with a little Python…

Essentially, chop the string back into its component parts, get rid of the bits you don’t want, convert the rest to numbers and reconstruct the points and lines… It is quite particular about list management, but i think this is about right…



StringToLine.dyn (45.3 KB)


Hers is the Python approach for the same

# Compiled by Amol Shah, August 2020
# @AmolShah1103

import clr
from Autodesk.DesignScript.Geometry import *

import re
regx = re.compile(r'((?:-)?\d+\.\d+)').findall

out = []
for str in IN[0]:
	line = Line.ByStartPointEndPoint(Point.ByCoordinates(float(regx(str)[0]),float(regx(str)[1]),float(regx(str)[2])),Point.ByCoordinates(float(regx(str)[3]),float(regx(str)[4]),float(regx(str)[5])))

OUT = out

Nice!! Thanks! But it seens that he turns negative points into positives

Thanks alot!! It works perfectly!

1 Like

No worries, welcome to the community.

In fairness to Dynamo, you can see how it allows you to review the output of each node as you go and check it. I love Python, but it is a bit more of a pain to do that.

You might now use ‘node to code’ to make it all a lot more compact now it is working…




@andrelud2 Thanks for pointing that out
I’ve update it in my code.


@andrelud2 Trying to understand the motive.
Would I be right to assume that the strings are exported to excel from a Dynamo file (where the lines were created) and you want to recreate those lines in a fresh file without recreating the preceding steps.

If that is the case, I’d suggest an alternate approach.
In the original file you could export the geometry to a .csv like this …

In the fresh file you could then import the geometry like this …


You are right, getting those lines from an export to excel from other dynamo file. Just tested here, works perftly! Nicely done, thanks!!

1 Like