Skip to content

Instantly share code, notes, and snippets.

@lin-ycv
Created May 25, 2022 12:45
Show Gist options
  • Save lin-ycv/60eaeb5f865faa497af5bf4823992e8c to your computer and use it in GitHub Desktop.
Save lin-ycv/60eaeb5f865faa497af5bf4823992e8c to your computer and use it in GitHub Desktop.
RhinoCS PictureFrame with Transparency
// 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