Possible to have RVB and Python work together?


#1

Hello, everyone. I just joined the forum today. I’m a long time user/developer in Rhino(3, 4, 5). Over the years, Rhino has allowed me to make a custom 3, 4, and 5-axis simultaneous CAM framework using RVB. Let me first say that Rhino is something that always strikes me with pleasant suprises of what it CAN do and what it allows me to develop.

Up to now I have used RVB to do what I need and am suprised at how FAST the calculations are made without having to revert to a lower level language. Rhino’s stability overall is top notch.

Anyway, I have quite a bit invested in RVB routines at this point and I have grown curious about Python. It seems Python has a lot more elegant functionality, particularly with respect to user interfaces.

I am wondering about the possibility of using Python to create user interfaces, and call upon those Python UI’s from within my RVB routines. I’d rather not take on porting everything to Python at this point. The main goal I wish to achieve here is to create a user experience that is faster, more robust and easy to use. What happens under the hood already I really have no need to change.

Thoughts?


(Dale Fugier) #2

I think you’d have an easier time creating your custom UI in a Rhino .NET plug-in and having RhinoScript call it than you would trying to call some Python script. You can write .NET plug-ins in either VB.NET (which is kind of like VBScript) or C#. And, the developer tools from Microsoft to create .NET plug-ins are free!

This information applies to Rhino 4, but you can use the same ideas with RhinoCommon .NET plug-ins with Rhino 5.

http://wiki.mcneel.com/developer/sdksamples/extendrhinoscript
http://wiki.mcneel.com/developer/dotnettorhinoscript


#3

Thanks, for getting back to me, Dale.

For the time being, I guess I am asking if it was possible to do what I had described. I understand it might not be optimal. There are some other forces at work here… unfortunately our IT department policies aren’t always helpful.

RVB and Python are things I already have at my disposal without having to fight for them. :smile:


(Dale Fugier) #4

It might be possible - something I’ve never tried. I’m not sure how you’d ever get parameters back and forth (between technologies)…


#5

Hmmm… I wonder if ‘document data,’ or ‘object data’ on an random object can be used to ferry parameters between them? I might play around with that a bit. What do you think?


#6

I suppose, worst case, I could write a temporary file in the working folder and use that to pass stuff back and forth. The trick would be to find a way to call on the python script. Perhaps I could write a section in the rvb to call the python script using rhino.command(you know… macro style almost).


#7

I guess I can see how a paranoid IT department (I think these terms are synonymous) might be a little testy about allowing an “ordinary user” (their natural enemy), especially one with demonstrated programming proficiency, from having a full Visual Studio installation, which includes C++ and unmanaged libraries and SDK, on a user machine.

On the other hand, I don’t think they can make much of a case for disallowing Visual Basic or Visual C# EXPRESS (both free from Microsoft) for .NET managed code programming. Have you tried that approach? I understand that the Visual Studio that comes with these is missing some tools that come with the full package, but it’s still got the important stuff. I haven’t used the express versions myself so I can’t make any specific comparisons, but maybe others can.

Another observation I can make from my experience is that IT departments don’t like change or special cases, which drives them to use their self-styled exhalted position of power to discourage any threat to the status quo. But they do have their mission and responsibilities to uphold. Just as you do in your job. My point is that since you have a good track record of innovation to improve your productivity, which depends on programming Rhino, and you want to stay current with developments. I believe you have a strong case for working through your management structure to a sufficiently high level that IT can be instructed to allow you to stay current with programming technology appropriate to your job, and to make it happen.

But I guess I can only guarantee that would work in my company, if I owned one. :smile:


(Steve Baer) #8

I messed around with this for a while and it really isn’t something I recommend that you do. It is possible, but really painful.


#9

Thanks for the input in this regard.

Bob


#10

In my experience, HTML works great for advanced UI with rhinoscript if you can get past the silliness of using both vbscript and javascript - assuming you want to use existing gui frameworks like jqueryui. McNeel missed the boat long time ago by eliminating javascript in favor of vbscript, and, while I have nothing against python, they missed it again recently by not leveraging javascript as a cross platform scripting language. The world runs on javascript and html.


(Dale Fugier) #11

Hey, you can still do this in V5:

<%@Language=JScript%>

function Hello()
{
  msg = "Hello from JScript";
  Rhino.MessageBox(msg);
}

Hello();

#12

I did what Dale suggested. It actually works great. I had a big rvb project grown over years but wanted to provide some more fancy and extended UIs with it. At first it was a little painful to pass more complex data structures back and forth between rvb and my customized UI function in C#. But in the end it all worked out very well. I can recommend this technique for all who work on legacy rvb projects which are too huge and painful to port to python or .net but still could benefit from some .net/rhinocommon enhanced functionality.

M