Importing Images from remote location (WMS-Service)

Hey, is it possible to import an image into grasshopper that comes from a remote server? E.g.

(It´s a image that is created “on-the-fly”)

Thanks in advance!

c# TextureMaterial from (8.1 KB)

Maybe it helps…

Hey Riccardo, thanks for the fast response. Unfortunatelly the image does not appear. I´m on mac.

I don’t own a single Apple hardware… I am not able to assist you :frowning:

Isn’t the component giving any sort of error?

Try to change the path string with a path you know can be freely used (so remove that “GetTempPath” …)

1 Like

I know much of Heron does not work on a Mac, but I am curious if the GdalWarp tool works. Can you give it a try? (12.0 KB)

1 Like

Hey Brian, the GdalWarp component throws an exception :frowning:

…the component does not give me any error. In fact it seems that it indeed output a “display material” but this one seems to be completly white.

…checked your advice to change the path string. ohmy god it works! :slight_smile:

So for all mac users: change c# component to:

 System.Net.WebRequest request = System.Net.WebRequest.Create(URL);
    System.Net.WebResponse response = request.GetResponse();
    System.IO.Stream responseStream = response.GetResponseStream();
    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(responseStream);
    string path = "/Users/your_name/Desktop/wms_nw_dop.png";
    bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Png);

    Rhino.DocObjects.Texture texture = new Rhino.DocObjects.Texture();
    texture.FileName = path;

    Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
    mat.SetBitmapTexture(texture, true);

Grasshopper.Kernel.Types.GH_Material GHmat = new Grasshopper.Kernel.Types.GH_Material();
GHmat.Value = mat;

TextureMaterial = GHmat;

Thank you Riccardo!

1 Like