Import XYZ points to 3D sketch?
SOLIDWORKS Forums
6 days ago

Hello,

 

I have many text files, each containing XYZ points. I need help creating a script that imports each text file as a 3D sketch with lines connecting the points.

 

I was able to use the code from this thread to import the points as curves, but based on the way I need to generate lofted surfaces, I need to import each text file as a 3D sketch. I was able to find this thread, with code that lets you convert cell values from Excel to a 3D sketch, but I need to be able to do this without going through Excel and instead, with a text file.

 

If not, would anyone know how to convert every imported curve into individual 3D sketches (one for each curve?) I would prefer not to do it this way as it means another step to get the sketches.

 

Thanks in advance for the help!


Categories: API∕Macros

Comments
Last comment By: Lance B.   Fri, 07 Dec 2018 17:25:43 GMT
Re: Import XYZ points to 3D sketch?

You can read text files or excel files.  It's just a matter of whether you are reading one by or orlooping through everything in a folder.  Google is your friend on this one.  There are many examples.  I believe you will need to reference Microsoft Scripting Runtime in your project.  Below is just a single text file example, but you could write a loop to cycle through all text files in a folder.

 

Dim strFilename As String: strFilename = "C:\temp\yourfile.txt"
Dim strFileContent As String
Dim iFile As Integer: iFile = FreeFile
Open strFilename For Input As #iFile
strFileContent = Input(LOF(iFile), iFile)

'do SW work here.
Close #iFile

By: Danniel Sims  Fri, 07 Dec 2018 00:13:24 GMT
Re: Import XYZ points to 3D sketch?
By: Artem Taturevych  Fri, 07 Dec 2018 02:38:43 GMT
Re: Import XYZ points to 3D sketch?

You could also look at the following thread: How to create a reference plane perpendicular to a line?

By: Nilesh Patel  Fri, 07 Dec 2018 04:30:52 GMT
Re: Import XYZ points to 3D sketch?

Thanks for the reply. I also found this script as well, though I need the points to be connected so I can loft the sketches together.

By: Lance B.  Fri, 07 Dec 2018 17:25:43 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.