Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
FS to import Excel list of XY data points
john_allen289
Member Posts: 38 PRO
Hi,
I am very new working with FeatureScript.
I have a long list of X & Y points in an excel worksheet. I want to build an FS custom feature that will read this excel worksheet and put a point in a sketch on the XY plane for each row pair of X & Y co-ordinates in the excel sheet.
Before I start is this possible with FS?
Any existing examples of any similar FS custom features anyone can share that do anything similar?
Any pointers or obstacles to look out for?
Thanks in advance.
John
I am very new working with FeatureScript.
I have a long list of X & Y points in an excel worksheet. I want to build an FS custom feature that will read this excel worksheet and put a point in a sketch on the XY plane for each row pair of X & Y co-ordinates in the excel sheet.
Before I start is this possible with FS?
Any existing examples of any similar FS custom features anyone can share that do anything similar?
Any pointers or obstacles to look out for?
Thanks in advance.
John
0
Comments
We have a tutorial on how to make sketches: https://cad.onshape.com/FsDoc/tutorials/add-sketch-geometry.html
See the "Importing external data" at https://cad.onshape.com/FsDoc/imports.html for more information.
For plotting on a plane it should be relatively straightforward, just depends on if you want to add the points as floating points in a Part Studio or if you want them to be sketch points. I find working with opPoint() to be easier, you just plug in the vectors you parse from the CSV file.
chadstoltzfus@premiercb.com
chadstoltzfus@premiercb.com
here's an example of using a csv to drive variables (by @john_mcclary), but it should be a good reference for how to get the data from the csv. https://cad.onshape.com/documents/75dfbb9091b5bea038398789/v/2d6edbf047281ce828b3923f/e/97a921379d1437bdaef7fcdf?jumpToIndex=1095&showReturnToWorkspaceLink=true
Set up a Document.
Created Excel list, two columns with 10 rows of X & Y data, exported to .csv, imported to the Document.
@chadstoltzfus I cut&paste your FS example, but I'm stuck on the CSV import line.
How do I get the Version for the imported .csv? I've versioned the document, viewed the version then copy for the URL, back to Main, paste the version id into the FS line but it's not working? Any thoughts? I;ve got the path to look at my .csv import 'XY Values.csv' but error is saying can't find module?
@chadstoltzfus FS
My FS
My URL in Main for the FS
Help please, thank you!
From there you should see an import statement appear in your code, and then place the "CSV::" chunk in front of you import statement. This will not only bring in the correct import statement but also reference the main of the document, so that way you will not have to create a version of the document every time you update the CSV.
To actually answer your question the version you could copy would be the sequence between /v/ and /e/ in the URL, it's much easier to just redo the import statement using the button up top.
chadstoltzfus@premiercb.com