Need to convert data from design optimisation (in the form of a .dat file) to .stl file using "convert voxels to stl mathworks script"
14 views (last 30 days)
Show older comments
I am new to MATLAB. I am required to use the x,y,z, coordiinates from a .dat file (consits of 1000s of rows and 3 columns) to generate a 3D stl file to open in CAD.
I require someone (maybe who has used the mathscript before) to guide me as to what file inside the script folder to edit.
Problem is, there are many files like, "Convert_voxels_to_stl.m", "Convert_voxels_to_stl_example.m", "READ.m" and "WRITE.m", "convert_meshformat.m" and an example called "Convert_voxels_to_stl_example.m".
My questions are:
- Which of the files should I edit or import my data into?
- What sort of lines should I focus on editing? Like the function arguments, or just the patching?
0 Comments
Answers (1)
Jasvin
on 7 Mar 2023
Edited: Jasvin
on 7 Mar 2023
As per my understanding, you have the X, Y, Z data for the grid in a .dat file that you want to convert to an STL file and you are using this FileExchange submission to do the same,
If this is correct, then you should first read through the CONVERT_voxels_to_stl_example.m script to see how the function is being called and how a .stl file is generated.
The example uses a .mat file but you can use the same for .dat files, you'll just have to load it in the same way,
load(<Filename.dat>)
But if you get difficulties with this load call, then you can refer to the discussion on the following MATLAB Answer, https://www.mathworks.com/matlabcentral/answers/79885-how-to-read-tabular-data-from-dat-files-into-matlab
And then call the, CONVERT_voxels_to_stl() method.
This is what the inputs and outputs mean as per the FileExchange documentation,
Converts the voxelised object contained within the 3D logical array <gridINPUT> into an STL surface mesh, which is saved to the ascii file <STLin>. The x,y,z axes for <gridINPUT> are defined by <gridX>, <gridY> and <gridZ>. The (faces,vertices) data are optional outputs.
So you must write a new script (.m file) that first loads the .dat file which will give you the x, y and z data and then call the convert() function. And you don't have to edit any of the FileExchange files, they are intended to be used out of the box.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!