How to save the result of stlwrite to a specific directory chosen by the user
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Oraib Ghaith AlKheetanRojas
le 23 Jan 2020
Commenté : marco mancini
le 20 Mar 2020
I am using the stlwrite to create an stl file out of a triangulted input, say for example I use f3 and v3 which are faces and verticies to create a triangulation and then convert that into stl. The stl saves in the same directory as code. I would like to have the option to ask the user of my code to chose a certain directory to save the file. how do I do that ?
TR = triangulation(f3,v3);
stlwrite(TR,'G.stl');
I am not sure I understand how uiputfile works.
0 commentaires
Réponse acceptée
Stephen23
le 23 Jan 2020
TR = ...
[F,P] = uiputfile('*.stl');
stlwrite(TR,fullfile(P,F))
2 commentaires
Rik
le 24 Jan 2020
You should replace the last two lines of code with the lines indicated by Stephen. That should not result in the error you describe and will avoid two issues: overwriting the path function with a variable, and failing to support operating systems that have \ as the filesep.
Plus de réponses (1)
marco mancini
le 16 Mar 2020
Hi,
could someone help me to solve this ERROR please?
I receive the following error using the stlwrite function:
Error using fileparts (line 37)
Input must be a row vector of characters or string scalar.
Error in stlwrite (line 70)
path = fileparts(filename);
Here my code:
X = randi(20,200,1)
Y = randi(20,200,1)
Z = randi(20,200,1)
% triangulate in xy
T = delaunay(X,Y)
% tet delaunay
tri = delaunayTriangulation(X,Y,Z)
% get surface faces and nodes
[F,P] = freeBoundary(tri);
% plot with trisurf
figure
trisurf(F,P(:,1),P(:,2),P(:,3),'FaceColor','red');
% now save
stlwrite(tri,'mytriangulation.stl');
thanks in advance,
Marco
12 commentaires
marco mancini
le 20 Mar 2020
Dear All,
I've just noted that the code above was generated with an old version of the the Sensor Array Analyzer.
I'd like to share the code generated with the latest version of the SAA and check with you if it is possibile to print the STL like Walter kindly showed with the previous method.
MAIN PROBLEM: When you run the code below, the figure get printed in STL, but the result is completely different from the figure you see in your editor (this issue was not happening in older version of SAA)
Here the code:
% MATLAB Code from Sensor Array Analyzer App
% Generated by MATLAB 9.7 and Phased Array System Toolbox 4.2
% Generated on 20-Mar-2020 19:09:54
% Create a uniform rectangular array
Array = phased.URA('Size',[4 4],...
'Lattice','Rectangular','ArrayNormal','x');
Array.ElementSpacing = [0.5 0.5];
% Calculate Row taper
rwind = ones(1,4).';
% Calculate Column taper
cwind = ones(1,4).';
% Calculate taper
taper = rwind*cwind.';
Array.Taper = taper.';
% Create an isotropic antenna element
Elem = phased.IsotropicAntennaElement;
Elem.FrequencyRange = [0 300000000];
Array.Element = Elem;
% Assign Steering Angles, Frequencies and Propagation Speed
SteeringAngles = [-30;0];
Frequency = 300000000;
PropagationSpeed = 299792458;
%Assign number of Phase shift quantization bits
PhaseShiftBits = 0;
% Create Figure
% Calculate Steering Weights
Freq3D = 300000000;
% Find the weights
w = zeros(getNumElements(Array), length(Frequency));
SteerVector = phased.SteeringVector('SensorArray',Array, 'PropagationSpeed', PropagationSpeed, 'NumPhaseShifterBits', PhaseShiftBits(1));
for idx = 1:length(Frequency)
w(:, idx) = step(SteerVector, Frequency(idx), SteeringAngles(:, idx));
end
% Plot 3d graph
format = 'polar';
% figure;
pattern(Array, Freq3D , 'PropagationSpeed', PropagationSpeed,...
'Type','directivity', 'CoordinateSystem', format,'weights', w(:,1));
% I ADDED THIS IN ORDER TO ALLOW THE PRINT OF THE STL
Model3D = pattern(Array, Freq3D , 'PropagationSpeed', PropagationSpeed,...
'Type','directivity', 'CoordinateSystem', format,'weights', w(:,1));
% export to STL
fvc = surf2patch(Model3D, 'triangles');
TR = triangulation(fvc.faces, fvc.vertices);
stlwrite(TR, 'STLM_apple.stl', 'text');
Thanks in advance for the contribution,
Voir également
Catégories
En savoir plus sur Model Import dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!