Polyline script

Hello good morning,

I have a set of x and y coordinates from Mat Lab that will create a curvilinear shape, I want to write a script that will draw this shape using a polyline based on the coordinates that I have. I barely started using python and I do not know if this is possible.

It is certainly possible, not very hard to do. The main question is how your text file is formatted. Most common would be each line with x <space> y , but different separators are also possible.

If there is no file header and nothing else special about your point coordinates file, you don’t even need a script. You can just import a space, comma, tab, or other character-separated file directly in Rhino to create the points. Look for the “points” file type in the import format choice. You can then create your polyline via the Polyline>Through points command.

HTH, --Mitch

There’s an import points example under help, that should get you started.


Mark

1 Like

Hey Mitch,

Sorry for the late response, thank you very much for your answer.
I have 1076 points so it takes few seconds to draw the shape of the curve. The next step is to extrude this shape but I will look into it and find out how I can do this.

import rhinoscriptsyntax as rs

side = rs.Command("_Polyline 5.74,10.35,0 5.75,10.35,0 5.76,10.35,0 …")

Hey Mark,

Thank you very much for your answer, I will look into it !.

Well, if this is just part of a script that does multiple operations on the data, then you definitely want to import the data via script as well. Mark posted a link to an example, let us know where you get stuck. I would try to avoid scripting Rhino commands and try to use native rhinoscriptsyntax.

Once you have imported your list of points (without adding them to the document yet) you can add the polyline to the documents simply by using rs.AddPolyline(pt_list) where pt_list it the list of your imported point data.

–Mitch

1 Like

Hello Mitch thank you for your explanation. I was able to import the data set of points and draw the polyline as well as to extrude this curve.
I would like to select just the part where these 3 extrusions intersect and delete everything else. I have been reading the python manual to see how I can do this and so far I think the “booleaninstersection” command is my best choice or do you know another way to do this?
Below is a picture of the drawing

Yes, BooleanIntersection should work. It works on two sets of objects, so you will need to choose one of them for one set and the other two for the other set.

–Mitch