Dynamic images (string manipulation)

Hello Everyone,

I wonder how I can manipulate a part of a string, here is what I want to accomplish:

the string “image path” is for example c:/file1.jpg, c:/file2.jpg, c:/file3.jpg, c:/fileN.jpg
now I want to change the image shown determine with an integer value, so that when my Int = 3 I get file3.jpg, when Int = 1 I want to see file1.jpg

How can I insert a variable into the image path? Or more general how can I integrate a variable into a string value?

Regards Johannes

You can create dynamic strings for the image path of a component. Just use an Expression binding and pass in a property for the file number like this example:"Builtin/Agitator/Agitator "+{Root Container.Image.status}+".png"The only problem is that you can’t fetch a file off of your hard drive. You have to import the files you want to use into the gateway using the Image Browser in the designer.

:thumb_right: thank you Robert!

Is there any way to dynamically add images into the gateway for use in the project? We have an application where we are directing picking operations in a warehouse. Typically we show an image of the current product to pick. This image comes from a network file with the product part number as the file name. We have been using custom software to do this (not Ignition). I am looking into replacing the custom interface software with Ignition but I have not found a way to duplicate this feature.

We’d be interested in this capability too. For an entirely different use though.

I was able to use the document viewer and pull a .gif image from my hard drive without going through the gateway import. You may be able to work that into your system.

That may work for Alex but for our use we need to be able to access the images from multiple workstations as we overlay polygons on the image (e.g. using a Paintable canvas) and it would become a nightmare to maintain image stores across multiple locations.
I realise we could have a network share and access the images from there but that would be difficult to set up as our network environment includes multiple VLANs that are Firewalled.

There are various other ways you could accomplish this.

  1. If you serve them up via a web server (IIS, apache, etc) then you can use them directly. Our image component will load any image over an [tt]http://[/tt] url. Just set the path property to the URL, and you’re good to go.

  2. If you serve them up over a windows file share or have them on the local computer, you can program up the Paintable Canvas component to display them, like so:

[code]from java.net import URL
from javax.imageio import ImageIO

Use this for a local file

#url = URL(“file:C:/my graphics/something.png”)

Use this for a windows file share

url = URL(“file:\\file_server\my graphics\something.png”)

icon = ImageIO.read(url)

event.graphics.drawImage(icon, 0, 0, event.source)
[/code]

Thanks Carl.
As usual you guys are right on the ball :thumb_left: