Scripting weirdness

Hi all,
I have a simple script that puzzles me: test.rvb (326 Bytes)
The goal is to scan an image from within Rhino.
The script works well except that I always get a “Server busy” error.

Now the weird thing is that when you change the extension of the script to vbs and run it it works without the error.

What is different from how Rhino runs it? Is there a way to suppress the error?

thanks, Tobias

Scripts run on the main thread. When you get to the image acquiring bit Rhino message pump probably doesn’t get messages, nor handled. When messages aren’t being pumped for a certain period Windows will pop up that message.

Not sure how to get around that. Probably spin off a thread in which you do the scan and in the main script periodically check if thread is done, combined with a call to RhinoApp.Wait (I think)

Thanks for your answer. Actually I don’t know how to “spin off a thread”… I’m using VB/RhinoScript. Might be not possible at all in VBscript?

Yah sorry, I don’t know about that. I realized the same after I had sent in the edit. We need input from the greats, like @pascal.

Oi… out of my league - I only ever type in the stuff - I don’t think rvb can handle threading but I may be making that up. in any case on the overall question… @dale- any idea?

-Pascal

Hi @tobias,

Does this help?

https://developer.rhino3d.com/api/rhinoscript/application_methods/displayolealerts.htm

– Dale

Whow Dale, fantastic! This is exactly what I needed. Works just perfect. Thanks!

While on the subject I have just one little problem left which you might be able to point me in the right direction: The ShowAcquireImage method returns just bmp’s, but the filesize is way to high. I need jpg.

So I found this page: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wiaaut/-wiaaut-icommondialog-showacquireimage and I tried to pass the right parameters to the method but with no luck. This is what I tried:

ShowAcquireImage(0,0, 65536, “B96B3CAE-0728-11D3-9D7B-0000F81EF32E”, False, False, False)

ShowAcquireImage(“ScannerDeviceType”,“UnspecifiedIntent”, “MinimizeSize”, “B96B3CAE-0728-11D3-9D7B-0000F81EF32E”, False, False, False)

ShowAcquireImage(ScannerDeviceType,UnspecifiedIntent, MinimizeSize, “B96B3CAE-0728-11D3-9D7B-0000F81EF32E”, False, False, False)

Do you know what I am doing wrong?

thanks a bunch,
Tobias

Looks like specifying the correct FormatID would be the magic.

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wiaaut/-wiaaut-consts-formatid

– Dale

Yeah, thats what I tried. I put “{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}” which stands for wiaFormatJPEG but the result is still a bmp:

7-8-2018%2023-09-41

Maybe the scanner doesn’t support jpg without using the vendors driver…? Just a guess

Never mind… I fixed it by converting the result to jpg with Wia.ImageProcess

Thanks again Dale!