Importing and exporting coordinates for an array of points

Hello All,

I have created a number of points, let's say for example 50 or a hundred points. Is it possible to export the point data to a file format (text file for example) where it can be imported later to create a spline or any other geometry using the Python API?

A second part to the question, how can I obtain the coordinates (x,y,z) of a point I draw in the GUI using a Python script? For a line for example we can get the start and end values, but I'm not sure how to do that for a single point.

Thank you for your time and help 😊

Not sure if that will solve your problems. To export results, go to the 'analysis' page, in the 'output view' section, right-click on the one you want to export, choose 'Imp/Export----Text Exporter'. Then in the properties section, click the 'Refresh' button and you can find the file in the FIle path folder.

To get coordinates, go to the 'model' page, choose the model, then click 'tool---Geometry'.

hi @mkn
here is some example code that exports the currently selected points as a csv file:

def dump_selected_points(fname):
    sel = XCoreModeling.GetActiveModel().SelectedEntities
    sel = XCoreModeling.CollectEntities(sel)
    with open(fname, "w") as file:
        for e in sel:
            if isinstance(e, XCoreModeling.Vertex):
                x = e.Position
                file.write("%g, %g, %g\n" % (x[0], x[1], x[2]))

Thank you, @fanruifu!

Thank you very much for your reply @bryn! I appreciate the help.