Command Bar Option that Chooses a Folder

I want to add an animation feature to my plugin using RhinoCommon, and I was able to implement screenshots in it and save them to a constant directory.

This can be made to be more convenient by allowing the user to choose which directory to save the screenshots in, but I’m not sure how to make a command bar option that allows you to do so and save the desired folder.

How would I accomplish my goal?

Also, if this is possible, is there a way to programmatically convert a list of pictures to a video file, like .avi or .mp4, using C#? That would be helpful as well.

rhinocommon runs in .net, ergo you have any number of video routines you can incorporate, I recommend if you need to get fancy otherwise .net already includes many basic image manipulation tools, pull emgu or simplecv from nuget. If you want gif I do recommend NOT using the .net available option and google for an api to include, .net natives wont allow frame timing. I wrote my own code to inject the delay bits between frames,

if you can avoid gif you are better off, but if you need the source for my capture app gif routine (see later in this video below) im happy to share, it was poached from an 80% useful python linux code I stumbled into.

if python is your weapon of choice there are a few .py’s around the place on the RPi forum that can help with GIF. Video in python is alo OpenCV, but no luck with simplifying the process as with simplecv or unfortunately, a lot fo code is longhand. Same app, same GIF function, but python/linux.

In terms of selecting a folder, that already exists in both the rhinocommon and .net filedialog option.


You can use a FolderBrowserDialog for this

It looks like there are several libraries out there that provide support for encoding video files. I just searched for “C# mp4 encoder” and got quite a few hits. I don’t have experience with these libraries so I can’t really make any recommendations.

this tickled me so I wrote one. I used the SHARP library and encode directly from the BITMAP object created by

Bitmap image = newview.CaptureToBitmap(size, false, false, false);

Nothing temporary written to disc except the video of about ~16-18mb. mjpeg codec in this clip but you can use one of about 10 supported codecs, the h264 codec gets same file down to 3mb…, but I stuck to mjpeg because its native in ALL windows installs… there is nothing worse than “you don’t have the correct codec to play this file…”

use your googlefu or nuget for the sharp library.



Wow, was that GUI your creation? Did you have to convert the python code to c#?

I’m definitely going to look more into, now that I just got my folder browser option operational. Thank you very much for your help!

Thanks for your help, I got my folder browsing option working now!

Not emgu. Sharp. I use emgu for my camera apication but its top heavy for this kind of thing. Sharp was dead simple.

Where do I find this SHARP library? I’m not sure what you’re referring to

Is this it?

Oops the library is called sharpavi not sharp. My apologies.

I only use Python in linux. Its a great language, akin to Basic in simplicity but the same simplicity can make it a major pita for someone that likes structure.

I’ve used Python before, but I was introduced to it years after I’ve developed a taste for languages like Java and C#. Thanks for the library recommendation, I got it to work! I found a different library that can convert video file types, and this website doesn’t allow .avi files to be uploaded, which is why I present a .mp4 file rather than a .avi file.

Glad you got sorted. Easier to just pop it on youtube and paste link here.

also… just FYI… if you have to write to disc and read back, forget windows giving you an easy to use human readable list of the files, it put 2 just after 20, 1 just after ten, the string weights are lower… but this works.

so used that sharpavi library in my other project, handy little thing isnt it… used it to backward engineer my GIF output too, the mjpeg output is far better than the native .net GIF handler.

It looks pretty good, how long did it take to reverse engineer it? My only concern is that the zoom function doesn’t retain its original resolution, it seems to be a bit more pixilated than the original.

depends on the webcam you use, some webcams will actually digital zoom, but most simply use native resolution ex 1080p, and will crop the perimeter border down to 960, 720p, 640p, 540p, 480p etc etc while keeping the same “resolution” as it were.

Second video above is 480P from a 720p webcam. Images of the build here:

to turn a regular cheap webcam into a macro cam is pretty easy too. remove the CCD lens housing and put a spacer under it, something spongy if you can, which allows you to screw it back to find the best focal distance without inducing too much DOF.