7

The following code helps me draw a polyhedron. I would like to color each triangular face in red and make the edges of the polyhedron thicker. I've looked at the post, but I'm still not sure how to do it.

   Show[Graphics3D[{Opacity[0.3], FaceForm[Blue], 
       PolyhedronData["SmallRhombicuboctahedron", "Faces"]}], 
     Boxed -> False]

enter image description here

licheng
  • 2,029
  • 1
  • 7
  • 15

5 Answers5

6

Step for step:

polygons = PolyhedronData["SmallRhombicuboctahedron", "Polygons"];

cor = PolygonCoordinates /@ polygons;

Find positions of triangular faces:

pos = Flatten @ Position[Length /@ cor, 3]

{19, 20, 21, 22, 23, 24, 25, 26}

Color them:

polygons[[pos]] = {Red, polygons[[pos]]};

Graphics3D[{Opacity[0.5], FaceForm[ RGBColor[0, 0, 1]], EdgeForm[{Thickness[Large], GrayLevel[0]}], polygons}]

enter image description here

eldo
  • 67,911
  • 5
  • 60
  • 168
5

Edit

faces = PolyhedronData["SmallRhombicuboctahedron", "Faces"];

faces /. Polygon[pts_] :> Insert [Polygon /@ GatherBy[pts, Length[#] == 3 &], Red, 2] // Graphics3D

enter image description here

Original

We change the strucure of the data of the PolyhedronData["SmallRhombicuboctahedron", "Faces"] to get faces1 and faces2

faces = PolyhedronData["SmallRhombicuboctahedron", "Faces"];
faces1 = 
 faces /. Polygon[pts_] :> Polygon[Select[pts, Length@# == 3 &]];
faces2 = 
  faces /. Polygon[pts_] :> Polygon[Select[pts, Length@# > 3 &]];
Show[Graphics3D[faces2], Graphics3D[{Red, faces1}], Boxed -> False]

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133
4
t = PolyhedronData["SmallRhombicuboctahedron", "Faces"];
polys = First@Normal@t;
cols = Scan[
      If[Length@MeshPrimitives[#, 1] == 3, Sow@Red, 
        Sow@Lighter@Blue] &, polys] // Reap // Last // First;
edges = Scan[
      If[Length@MeshPrimitives[#, 1] == 3, Sow@Thick, Sow@Thin] &, 
      polys] // Reap // Last // First;
Graphics3D[{
  MapThread[{FaceForm[Opacity[0.7, #1]], EdgeForm[#2], #3} &, {cols, 
    edges, polys}]
  }
 , Boxed -> False
 ]

enter image description here

Syed
  • 52,495
  • 4
  • 30
  • 85
4
styles = FaceForm[Opacity[.5, #]] & /@ {Green, Orange};

PolyhedronData["SmallRhombicuboctahedron", "Graphics3D"] /. 
 p_Polygon :> Map[{styles[[5 - Length @ #]], Polygon @ #} &] @ First @ p

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
3
Show[Graphics3D[{Opacity[0.3], FaceForm[Red], 
   EdgeForm[Directive[Thick, Green]], 
   PolyhedronData["SmallRhombicuboctahedron", "Faces"]}], 
 Boxed -> False]

enter image description here

David G. Stork
  • 41,180
  • 3
  • 34
  • 96