Created
May 25, 2022 12:45
-
-
Save lin-ycv/60eaeb5f865faa497af5bf4823992e8c to your computer and use it in GitHub Desktop.
RhinoCS PictureFrame with Transparency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get png's | |
string[] files = System.IO.Directory.GetFiles(dir); | |
int i = 0; | |
if(place) | |
{ | |
foreach(var pt in loc){ | |
// Add PictureFrame | |
var id = doc.Objects.AddPictureFrame(// Guid | |
new Plane(pt, Vector3d.XAxis, Vector3d.ZAxis), // Plane | |
files[i], // FilePath | |
false, // As Mesh | |
w, // Width | |
h, // Height | |
false, // Self-Illuminating | |
false); // Embed Bitmap | |
//F ind picture frame | |
var obj = doc.Objects.FindId(id); // Rhino.DocObjects.RhinoObject | |
var rm = obj.RenderMaterial; // Rhino.Render.RenderMaterial | |
// Set Transparency | |
rm.BeginChange(Rhino.Render.RenderContent.ChangeContexts.Program); | |
rm.SetParameter("alpha-transparency", true); | |
rm.EndChange(); | |
obj.CommitChanges(); | |
// Use all avilable png | |
i++; | |
if(i >= files.Length)i = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment