algorithmic modeling for Rhino

Hi all,

I am building a simple custom GH component in C# that generates a brep and assigns a texture to it. See attached code.

The problem is that I would like the code to assign the texture (.bmp file) directly from the Resources internal folder. So far I managed only to assign it via the external path to the original Visual Studio project.

I tried to use the GetExecutingAssembly().Location but I get a null value for it.

Any ideas?

Views: 1041


Replies to This Discussion

Hi Jacopo,

I think you need to save the image to a file, then use that path for a link. You cannot directly link with the path of the .GHA assembly.

I will ask someone from the Render Development Kit (RDK) team to have a look at this and say if there are more suggestions.

Internal tracker reference link: RH-39728.


Giulio Piacentino
for Robert McNeel & Associates

Thanks much Giulio! Looking forward to receiving the answer!



OK, I have come up with a temporary, but not really preferred, solution.

I am just copying the texture from the Resources folder to a local folder of the user's machine and then reference it back in the GH component.

Not really elegant, yet, effective. Updated code attached.

Looking forward to the "official" answer!



As far as I can see this is the way to do it at this time.

I'll be looking into creating a custom texture with custom evaluator, but no promises on that. Your safest path is to use the saving method.

Another is of course to not embed the image, but to deliver it with the plug-in you are writing...

Hi Jacopo,

I created a MemoryBitmapTexture for Rhino WIP, but the code for it is easy and can be freely shared:

You can add the two classes MemoryBitmapTexture and MemoryBitmapEvaluator in a regular v5 RhinoCommon plug-in, and load that into Rhino 5 before trying to use it.

The test command in the gist should give you enough info to use the texture.

Note again that this custom texture is already in Rhino WIP master branch, and should be available on the next public WIP release.

If you have questions, please let me know.

Hi Nathan,

thanks for the code. I have added the two classes to the project, but a series of properties and methods are missing - I am still using the v5 of the RhinoCommon dll.

Here attached the error list when building the project.

Is there something I am missing?



I modified to code to compile on v5. I seem to be unable to get the component to instantiate the RenderTexture implementation from your component.

I think we need David Rutten to have a peak, because I'm not sure why the setup isn't working...


After some more tinkering I think it may be impossible to get MemoryBitmapTexture properly working in v5. In Rhino WIP (v6) it should work OK.

Therefor I think it is best to continue with the method of saving to an external file in v5 Grasshopper.

Thanks much Nathan for the support, really appreciated!

Looking forward to using the new version then! In the meantime, I'll do it the "artisanal" way!

Jacopo, would you be willing to outline how you accomplished the "copying the texture" workaround in your plugin? 

I still haven't fully implemented it, but I plan on following these steps:

1- upload the .bmp file in the internal "Resources" folder of the plugin when developing the plugin

2- once the plugin is distributed, during the "solve instance" method, check if the .bmp file has been saved in a specific folder on the the user's machine, or ask the user to select a folder where the bmp will be stored

3- set the "FileName" property of the "Texture" object to the fully-referenced path to the .bmp file on the user's machine

4- assign the texture to the DisplayMaterial object via the SetBitmapTexture method

You can find part of the above code in my answer on 16th June (only the check at step 2 is missing):

Hope it helps. Let me know if something is still missing!






  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service