How to make a geometry transparent?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bacha Munir
le 10 Juin 2024
Modifié(e) : VINAYAK LUHA
le 12 Juil 2024 à 5:03
Hello brothers. I have a geometry and I want to make it transparent as some entities are disappeared. I have used the following commond but no results. Thank you.
gm=mphgeom(model)
mphviewselection(model,gm, 'facealpha', 0.5)
1 commentaire
DGM
le 10 Juin 2024
Modifié(e) : DGM
le 10 Juin 2024
I don't know what those functions are, but the only thing in the figure are two patch objects. You can just set their FaceAlpha to 0.5. One of the objects is used for creating the wireframe edges. The other is used to shade the faces, so figure out which is which and adjust the facealpha on the one that's used for the faces.
Réponse acceptée
VINAYAK LUHA
le 12 Juil 2024 à 5:02
Modifié(e) : VINAYAK LUHA
le 12 Juil 2024 à 5:03
Hi Bacha,
I understand that you have a MATLAB figure consisting of several closed entities and you want to make the geometry of these entities 'translucent' so that the inner entities are also visible.
This can be done by adjusting the 'faceAlpha' property of the enclosing "patch" graphics objects in the figure.
Following code snippet shows the implementation based on the above logic -
fig = openfig('figure 2.fig')
% Get all the children of the figure
allChildren = findall(fig, '-property', 'FaceAlpha');
% Loop through each child and check if it is a patch object
for i = 1:length(allChildren)
child = allChildren(i);
if strcmp(get(child, 'Type'), 'patch')
% Set the transparency (FaceAlpha) to a desired value, e.g., 0.5
set(child, 'FaceAlpha', 0.5);
end
end
Result -
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1733033/image.png)
For more details on the functions used, kindly refer the following documentations :
- Modify graphics objects - https://www.mathworks.com/help/matlab/creating_plots/graphics-objects-overview.html
- patch function - https://www.mathworks.com/help/matlab/visualize/introduction-to-patch-objects.html
- findall function -https://www.mathworks.com/help/matlab/ref/findall.html
Hope this answers your question
Regards,
Vinayak Luha
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Polygons 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!