[Closed] viewImage() – Doesn't Function Via Script
I’ve only really seen one instance that even remotely describes a problem similar to what I am encountering, that issue can be found here: http://forums.cgsociety.org/showthread.php?f=98&t=696062&highlight=viewImage()
My Problem:
I’m creating a Standard Material Extension that is for a specific game asset creation workflow.
This requires output of maps with crop values. Our users need to be able to quickly and easily access the Bitmap viewimage VFB for setting the crop placement and moving onto the next item.
What happens when I try to view the image?
temp = delegate.diffuseMap.MapList[2].map1
if classof temp == BitmapTexture do
(
temp.viewImage()
format "Image SHOULD be open.
"
)
This presents me with plenty of text that the Image should be open, but I never get a visible window!
I’ve also tried the method of bitMapTex.viewImage temp.
This does not work either.
On a bitmapTexture doing display (temp.bitmap) displays the VFB, but none of the cropping/placement information.
Can anyone advise on a solution/workaround?!
I’m at wit’s end here.
Thanks!
In the quoted code, the print is “Map #33:Bitmap”
I can copy that into Material Editor Slot 2, and click on the view image button to open it, but the code to view it still does nothing, even if I call it in slot 2.
Tried that. It returns “OK”
I’ve taken my bitmap, thrown it onto the diffuse slot of medit[2] and done:
meditMaterials[2].diffuseMap.filename
returns “D:\Documents\colormap.bmp”
doesFileExist (meditMaterials[2].diffuseMap.filename)
returns “True”
dif_map = meditMaterials[2].diffusemap
if classof dif_map == BitmapTexture do dif_map.viewImage()
This returns “Map #33:Bitmap
OK”
Now, If I perform any of these options on a freshly placed bitmap, life is good, code works.
When I take any of the working code, and place it into my Material, the code executes and does NOT display the map.
I’ve reloaded the image, I’ve tried everything, but as soon as I call the map from the material, the code above that just worked, no longer works!
from the thread you linked to:
.viewImage() seems to only work when medit is open -and- the map I’m calling it on is the currently active medit slot.
Are you driving the medit interface via max script to make sure this is the case?
I have. And this has not yet yielded any better result unfortunately.
The material I am working on is the one I am trying to open.
.viewImage() seems to only work when medit is open -and- the map I’m calling it on is the currently active medit slot.
It doesnt seem to even work that way.
Try this:
- Build 2 different materials with 2 different diffuse maps.
- Open the material 2 in the Material Editor and go to the diffuse map
- Now reference the bitmap of the material 1 and call viewImage() on it
On my end it opens the bitmap of material 2 instead.
So it appears to simulates the pressing of the View Image button (as stated in the help), but without considering the bitmap you are passing on.
Weird, because there are even other examples in the Help->Interfaces section that show the use of viewImage(), which also do not work.
.viewImage() seems to only work when medit is open -and- the map I’m calling it on is the currently active medit slot.
that’s true. the viewImage window is an editing control. it opens only for current texture map opened in material editor. if you close material editor, it closes the image window too. so… it’s a feature. probably one of the bad features…
I really appreciate you taking the time to test and write out these steps. That was about the only thing I hadn’t done.
On several occasions I had inadvertently experienced this without knowing it, as I was working with the bitmap in many places to try and get a working solution.
calling .viewImage() on just about any bitmap object will ONLY open the bitmap that has focus in the material editor. So I’d agree with Dennis, this is an awful bug.
But, alas. I cannot fix the bug, so I’ll work around it in a less than pretty manner.
Thanks everyone for the assistance!