# AddPictureFrame but Transparent

**URL:** <https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331>\
**Category:** Rhino Developer\
**Tags:** windows\
**Created:** [April 19, 2022, 2:27pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331 "2022-04-19T14:27:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.birch.uk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/david.birch.uk/32/610361_2.png) [@david.birch.uk](https://discourse.mcneel.com/u/david.birch.uk)\
**Post date:** [April 19, 2022, 2:27pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/1 "2022-04-19T14:27:02Z")

</div>

Hi there,

I have been using this method to load an image. It works well.

> **[ObjectTable.AddPictureFrame Method](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_ObjectTable_AddPictureFrame.htm)**
>
> Creates a PictureFrame object from a plane and a path to an image file, Note, a PictureFrame object is just a Plane surface or mesh that has a material with a texture assigned to it that displays in all display modes.

We would like to import the image and make it transparent - This method does not support this.

**Is it possible to modify the created RenderMaterial to add transparency?**

If not I suspect we should create our own Material, I see [this](https://developer.rhino3d.com/samples/rhinocommon/add-texture/) tutorial however I am not sure how to modify to create a transparent material

any advice appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [April 19, 2022, 2:37pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/2 "2022-04-19T14:37:57Z")

</div>

You should be able to retrieve the object from the object table, then query for its RenderMaterial and change the transparency setting using the SetParameter method on the RenderMaterial.

Once you have retrieved the RenderMaterial

```nohighlight
RhinoObject obj = doc.Objects.FindId(guidFromAddPictureFrame);
RenderMaterial rm = obj.RenderMaterial;
rm.BeginChange(RenderContent.ChangeContexts.Program);
rm.SetParameter("transparancy", 0.5);
rm.EndChange();

```

Here some more examples of how to create and manipulate RenderMaterials: [https://jesterking.github.io/rhipy](https://jesterking.github.io/rhipy)

They are in Python, but use the RhinoCommon SDK. It should be straightforward to translate those to C#.

---

<div class="post-metadata">

**Author:** ![david.birch.uk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/david.birch.uk/32/610361_2.png) [@david.birch.uk](https://discourse.mcneel.com/u/david.birch.uk)\
**Post date:** [April 19, 2022, 2:49pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/3 "2022-04-19T14:49:55Z")

</div>

Thanks Nathan, that is super helpful

I can now see this in the render panel  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/5/f/95f44b6470df23756bb827ec7f885c6dadfc6db0.png)

however the plane does not appear transparent.  
If i move the slider it suddenly becomes transparent  
Did we miss an apply / commit?

code below (fixed typo in transparA//Ency spelling)

```auto
var id = doc.Objects.AddPictureFrame(plane, tempFileName, false, image.Image.Width * settings.XScale, image.Image.Height * settings.YScale, true, true);
var o = doc.Objects.Find(id);

o.RenderMaterial.BeginChange(RenderContent.ChangeContexts.Program);
o.RenderMaterial.SetParameter("transparency", 0.9);
o.RenderMaterial.SetParameter("alpha-transparency", true);
o.RenderMaterial.EndChange();
o.CommitChanges();

```

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [April 19, 2022, 2:59pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/4 "2022-04-19T14:59:08Z")

</div>

As far as I can tell those are the changes needed.

I am not sure if it makes a difference but maybe do:

```nohighlight
RenderMaterial rm = o.RenderMaterial;
// .. set parameters bracketed by Begin/EndChange
o.RenderMaterial = rm;
o.CommitChanges();

```

That ought to be enough.

---

<div class="post-metadata">

**Author:** ![david.birch.uk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/david.birch.uk/32/610361_2.png) [@david.birch.uk](https://discourse.mcneel.com/u/david.birch.uk)\
**Post date:** [April 19, 2022, 3:06pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/5 "2022-04-19T15:06:05Z")

</div>

Yeah that works! thank you

I am not sure why making the assignment helps but it does!

complete solution:

```auto
var o = doc.Objects.Find(id);
var material = o.RenderMaterial;
material.BeginChange(RenderContent.ChangeContexts.Program);
material.SetParameter("transparency", 0.5);
material.EndChange();
o.RenderMaterial = material;
o.CommitChanges();

```

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [April 19, 2022, 3:09pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/6 "2022-04-19T15:09:36Z")

</div>

Assigning the render material explicitly ensures the object attributes get properly flagged for update so that the call to CommitChanges actually does something.

Your first method never sets the RenderMaterial property on the object, only gets from it. Just having the material changed is not enough clearly (:

A bit finnicky, but that is how it is designed.

I should add an example to my literate page that explains this clearly.

---

<div class="post-metadata">

**Author:** ![david.birch.uk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/david.birch.uk/32/610361_2.png) [@david.birch.uk](https://discourse.mcneel.com/u/david.birch.uk)\
**Post date:** [April 19, 2022, 3:16pm UTC](https://discourse.mcneel.com/t/addpictureframe-but-transparent/141331/7 "2022-04-19T15:16:40Z")

</div>

That makes sense, yeah an example would be great
