Importing coordinates into SW

I’m using SW 2024 & Excel 2019 (via MS Office). Someone on Reddit was asking about importing Excel based XYZ coordinates into SW, typically to make a curve from the data although there are probably other general purposes (more on that later). Anyway I haven’t done this for some time, but I know I have in the past on prior SW version. I’m pretty sure I just had 3 columns in Excel containing XYZ data, no headers or blank rows, did a File save file type Text.

Then from within SW followed the method described similarly in many links: Select Curves, Curve through XYZ Points, pick the TXT file & it generates a curve. For some reason this familiar method failed. I keep getting this error popup.
SNAG-26-02-2025 7.32.03 PM.jpg
Tried some other things like saving as CSV with various delimiters but nothing worked because SW will only import TXT . Today I found this link made some progress & maybe some indication of where the problem may be. The link discusses pretty much exact same work flow. But I noticed their XYZ source data was from a file showing Notepad, which is .TXT

https://grabcad.com/tutorials/tutorial-how-to-import-points-to-solidworks-from-a-text-file

So I created a test using Notepad coordinates & it worked perfect. I then used the exact same data from within Excel, saved as file type TXT (dropdown = Text, tab delimited) & again it failed to open in SW, same error message. So my hunch is there is something about how Excel is delimiting the data when saving to TXT. Yet when I look at both TXT files using Notepad side by side they look the same. Maybe there is another app that can better highlight the delimiter differences? In Excel AFAIK there are no other options as to how to delimit specific to TXT files the way you can in .CSV. But SW will only import 2 formats this way .TXT & .SLDCRV (a Solidworks curve file whatever that is).

So back to replicating Notepad method, here is what I did.

  • create your Notepad file
  • open SW Start but don’t make a sketch yet. Select Curves, Curve through XYZ Points.
  • browse for the TXT file (you may have to click this filetype in lower right drop down). It should successfully load in previewer.
  • Now the weird part is it must somehow be aware of the SW template being used because for example it concatenates mm to the text values, so my 1.0 becomes 1.0mm. But anyway then it builds a curve through the data.

I understand there are macros that facilitate this task of reading from Excel (but I’m also reading other posts where they are failing). I’m wondering if the macros are doing some data / delimiter conditioning so SW is happy? Maybe I copy/paste Excel data into a Notepad file but that seems clunky. Really too bad SW doesn’t facilitate CSV vs TXT because there are many more options with CSV.

Anyway, sorry for long ramble. just wondering if others have similar issues or can make suggestions in this regard
SNAG-27-02-2025 10.14.16 AM.jpg
SNAG-27-02-2025 10.14.27 AM.jpg
SNAG-26-02-2025 7.32.03 PM.jpg

Here is what the file imported screen grabs & resultant curve look like.
SNAG-27-02-2025 10.06.44 AM.jpg

On this subject, I thought there was a way to just import ‘points’ as opposed to the curve method which is obviously connecting the XYZ points from another file. Any suggestions or am I hallucinating?

I’ve used this with success to import points.

https://www.cadforum.net/viewtopic.php?t=934

Thanks Sperman. Sorry in advance because I should probably direct my question to the macro author, but hoping its something simple.

  • I downloaded the 2 sample CSV files & Point Cloud macro
  • I copy pasted code into a new macro
  • I left FIRST ROW HEADER as TRUE because file has a header row
  • I changed SYSTEM UNITS to FALSE, as per instruction
  • left everything else as-is
  • opened a new sketch, executed macro, when I point to the CSV file it gives me attached error. I tried copy pasting full path into the dialog field as well, same error
    SNAG-27-02-2025 1.15.58 PM.jpg

How many rows are in your point table?

When it throws up the error, is there a row of code highlighted in yellow?

As a swag, find this line and change

Dim i as Integer

to

Dim i as Long

image.png

I downloaded their sample file as-is & did not modify contents, just moved to my SW folder which is what I pointed to including full path.
I tried file points-3d.csv To answer your question, it contains 1 header row plus 3 rows of XY data, 4 rows in total.
Maybe I should try to step through the code & see where it hangs. I’m a macro rookie, but just got myself set up on some training.
Also, maybe a misstep on my part, when I created a new macro, I pasted in the macro contents directly, no other code (screen grab of top of code)
SNAG-27-02-2025 2.00.06 PM.jpg

Hmmm.. I used F8 to step through the code (walking blindly here). After I specified the file name/path, it didn’t immediately complain. I got the impression it was looping. Then maybe got to bottom & then died?
SNAG-27-02-2025 2.03.25 PM.jpg

Well back to my original workflow problem of generating a curve from an Excel generated text file, a solution was provided to me so passing on the good news

  • a prerequisite is the Excel .txt must be closed before initiating the file browse from inside SW. It doesn’t matter if the File save As name.txt has already occurred, the issue is that Excel is open & therefore kind of linked. I think this is what the error popup is trying to say - its being used in another application. Close it & it loads perfectly fine

  • I made a mistake. Excel can save in 3 different .txt file formats & I tested all 3: Text (Tab delimited) *.txt = imports fine. Text (MS-DOS) *.txt = imports fine. Unicode text *.txt = did not load, gave me error message “the data in this file may be invalid”.
    SNAG-01-03-2025 1.28.11 AM.jpg
    SNAG-01-03-2025 1.05.35 AM.jpg

Thanks for posting your notes on the Excel import. I’ll probably visit this thread some day.

Dwight