stl file rendering is not working can you help me to solve it?

5 ビュー (過去 30 日間)
abu sharique shamshad khan
abu sharique shamshad khan 2021 年 8 月 20 日
回答済み: DGM 2025 年 7 月 14 日
FV = stlread('sample.stl');
trimesh(FV)
patch(FV,'FaceColor',[10 10 10],'EdgeColor','none','FaceLighting','gouraud','AmbientStrength',15);
% Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');
% Fix the axes scaling, and set a nice view angle
axis('image');
view([-500 500]);
Error using patch
Not enough input arguments.
Error in PART1 (line 3)
patch(FV,'FaceColor',[10 10 10],'EdgeColor','none','FaceLighting','gouraud','AmbientStrength',0.15);

回答 (2 件)

Simon Chan
Simon Chan 2021 年 8 月 20 日
編集済み: Simon Chan 2021 年 8 月 20 日

You may need trisurf or triplot (2D) instead of function patch.


DGM
DGM 2025 年 7 月 14 日
This problem is caused by trying to feed a triangulation object to patch(). MATLAB stlread() returns a triangulation object, not a simple FV struct. This confusion happens because users find old code based on older third-party decoders with the same name and different output behavior.
Something like trisurf() or trimesh() should be able to directly take the triangulation object, but you can still use patch().
unzip stepholecube.stl.zip % for the forum
% import it
T = stlread('stepholecube.stl'); % this is a triangulation object
F = T.ConnectivityList; % you can get the F,V data
V = T.Points;
% plot it however is appropriate
patch('faces',F,'vertices',V,'facecolor','w','edgecolor','k');
view(3); view(-30,47); camlight;
axis equal; grid on

カテゴリ

Help Center および File ExchangeSTL (STereoLithography) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by