Importing Solidworks 2D Geometry into MATLAB

Hello, I'm quite new to MATLAB but I was wondering, how can I import 2D Geometry coordinates from Solidworks into MATLAB? The ultimate goal would to get these geometry coordinates (specifically the distance from the origin to the Y coordinate of the contour, which the geometry is half of a rocket engine contour), to get the datapoints of the ratio of Area/Area of the throat along the entire contour.
Hopefully that makes sense,
Thank you for any help

3 Kommentare

Mario Malic
Mario Malic am 29 Sep. 2023
I am not sure if MATLAB is suitable for this task. What are you trying to extract is not clear to me so please describe it in more detail. In the meantime I would suggest that you try VBA macros in SolidWorks to extract the data for your curve in the text format.
KSSV
KSSV am 29 Sep. 2023
In what format the file is? STL ? You can happily import stl files.
Matthew
Matthew am 1 Okt. 2023
@Mario Malic Yeah I'm not sure if it was possible in Matlab either (im also probably new to this which might limit my understanding of whats possible), but here I'll try to explain it better. In the picture I sent (I just grabbed this off the internet), I'm trying to import my contour (Which is 2D and is a 1/2 cross section) in a way that I could obtain the varying radius of the contour as I travel from the start to the end. I'll then use this radius to calculate isentropic flow equations. Though I'm not sure if MATLAB could read coordinates (? if thats the right word) from Solidworks.Hopefully u get a better idea now

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Avni Agrawal
Avni Agrawal am 9 Okt. 2023
Bearbeitet: Avni Agrawal am 9 Okt. 2023
Hi,
I understand that you want to import 2D geometry coordinates from Solidworks, specifically an STL file, into MATLAB. You can achieve this by using the "importGeometry" function in MATLAB's PDE Toolbox. You can find more information about this function in the MATLAB documentation here: https://in.mathworks.com/help/pde/ug/pde.pdemodel.importgeometry.html#bulkov_-4
Here's an example of how you can import geometry using the "importGeometry" function in MATLAB's PDE Toolbox:
% Create a PDE model
model = createpde();
% Import the geometry using the importGeometry function
importGeometry(model, 'rocket.stl');
% Plot the imported geometry
pdegplot(model, 'FaceLabels', 'on', 'FaceAlpha', 0.5);
% Further processing or analysis of the imported geometry can be done here
% Display a message to indicate successful geometry import
disp('Geometry imported successfully.');
To extract the coordinates from the STL file and import them into MATLAB, you can use the "stlread" function. Here is an example that demonstrates how to do this:
% Import the STL file using the stlread function
[vertices, faces] = stlread('rocket.stl');
% Extract the coordinates from the vertices
x = vertices(:, 1);
y = vertices(:, 2);
z = vertices(:, 3);
% Process the coordinates as needed
% (e.g., calculate distances, ratios, etc.)
% Your further MATLAB code goes here
% Display a message to indicate completion
disp('Coordinates imported successfully.');
I hope this explanation helps you with importing the 2D geometry coordinates from Solidworks into MATLAB.

4 Kommentare

Mario Malic
Mario Malic am 12 Okt. 2023
Does this work with extracting coordinates along the curve @Matthew?
Matthew
Matthew am 14 Okt. 2023
Bearbeitet: Matthew am 14 Okt. 2023
@Mario Malic I just tried it out today and No, I can't extract all the coordinates along the curve. I should've specified earlier but my geometry looks like this (Image attached), so it's not exactly a smooth curve. Should've known by the vertices function that this wouldn't exactly work (Since I only have 6 vertices). Is there any way I can get coordinates of the curve I sent? And is there some node interval I could do as well? (For example, every for 0.1in in the x-direction, get the y-coordinate?). Any help would be appreciated, or if this is doable at all. I thought about representing the lines as simple functions but I would like to do it from the import geometry approach to lay as a groundwork for other contours/curves.
Also hopefully you understand what I'm trying to do judging by your oldest comment, i.e get the coordinates so.
(0,5), (0.1, 5), (0.2, 5)....until it reaches the end.
I'm a bit worried about the vertical straight lines messing with the data.
Mario Malic
Mario Malic am 15 Okt. 2023
What is the that curve you are trying to obtain the points from - arc, spline?
Matthew
Matthew am 15 Okt. 2023
Bearbeitet: Matthew am 15 Okt. 2023
@Mario Malic The "curve" is just straight lines in Solidworks, no arc or splines. I will also try your macro later today.

Melden Sie sich an, um zu kommentieren.

Mario Malic
Mario Malic am 15 Okt. 2023

0 Stimmen

Here is a SolidWorks macro, you have to select the edge and run the macro. Hopefully it works, otherwise you need to tell me what kind of curve is used to draw the edge.

Tags

Gefragt:

am 28 Sep. 2023

Bearbeitet:

am 15 Okt. 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by