Distributing Python Commands

Is this Rhinoscript compiler still the best way to distribute python commands?

We now have support for Python in the .RHI (Rhino Installer Engine) format. Perhaps that’s an easier option?

Thanks for the reply @will. I haven’t had much luck with either method, but will try again.

@Ncik I’ve started a new topic, since the last one was three years old. What isn’t working, specifically, with the RHI method? Feel free to attach your .RHI or .py files (or send them to me privately) and I’ll take a closer look. I rewrote the guide last year and everything was working fine then!

So, I’ve tried again but there is a mess.

First Problem
After the rhinoscript compiler rhi file was used the _cmd versions of the commands became available in the command line, but don’t work. How do I get rid of these?

Second Problem
We’ve previously had the commands working following this distribution method.

But I added another command and bug-fixed some others. Following the same procedure we cannot now replace the original commands, and the originals are no longer available (moved the original directory into an archive).

Second Problem is fixed.

First problem is still hanging around. Any ideas?

All problems sorted.

Just use this…

Does anyone know if I can include/install python commands with a regular C# plugin?

We have a plugin that has most of its logic inn C#, but we also wrote a few utility functions in Python. I would like to be able to install all of these with a single installer.

@Jack_Minardi The Rhino Installer Engine will only recognise an RHI package as either a C++/.NET plug-in or a Python plug-in.

@piac – is it possible to wrap Python files and invoke them from C#?

Hi @will, it surely is possible, but it’s not ideal. The user would lose the ability to change the code, or possibly customize it. Unless that is requested.

Could the ability to install both Python and .Net/C++ assemblies be added to the Rhino Installer Engine?

I’ve been struggling to make this work. I’ve created a Python script for a client and I’m trying to create an installer for him, but I keep getting “An unexpected error has occurred during installation”.


I’m not sure what I’ve done wrong, this happens when I try it with the RHI file created by following the Creating Rhino Commands Using Python guide.

Attached is the RHI file.
MyNewPlugin.rhi (868 Bytes)

I have two Windows 10 virtual machines that I’m testing this on.

Any help would be awesome!

Thanks,
Torey

Hey @torey, you need to zip the contents of the dev folder. The __plugin__.py file and any *_cmd.py files should be in the root of the RHI package. I’ve tweaked your RHI package and attached it below, as an example.

MyNewPlugin_fixed.rhi (732 Bytes)

@will That’s awesome! The instructions were soooo clear, but somehow I missed it :wink:

I appreciate the help!

1 Like

Hello, can I ask, what exactly does the __plugin__.py do.

And could it be used to load a .rui toolbar for example.

Hey @cokepe,

.NET and C++ plug-in assemblies already contain information that Rhino uses to determine the plug-in’s name, version and unique ID. The Rhino Installer Engine also uses this information to decide where to install a plug-in. For Python plug-ins we use the __plugin__.py file to contain this information.

For more, see http://developer.rhino3d.com/guides/rhinopython/creating-rhino-commands-using-python/#creating-an-rhi-installer

Unfortunately the name, version and ID are the only information that is extracted from the __plugin__.py file.

Thanks for your answer,
I was hoping to avoid to create a pug-in in .NET, in order to distribute a few python scripts and a toolbar asociated.
I’ll just add a script that load the toolbar.

Thanks again.

G’day Everyone,

This still doesn’t work intuitively.

__plugin__.py edited with new version number (1.0.0.5)
dev directory files zipped including __plugin__.py
renamed to RHI and transfered to another machine
double clicked the RHI, with the “Anyone who uses this computer” option, it extracts successfully to Common Files/…

instead of AppData/Roaming/… as per my installation

run editpythonscript as per the Note
commands are not recognised so do not run

Even copying from Common Files/… to AppData/Roaming… doesn’t work. Editpythonscript has no affect after this step either.

What am I doing wrong?

Should I pick the “Just Me” installation option? Is the name MyNewPlugIn not optional? Do I need to manually delete the previous version? Grasping at straws here.

The 1.0.0.4 version eventually worked after a similar distribution problem so clearly I’m missing something important.

Rhino 5 SR14

regards,
Nick

Hi @Ncik, you need to select “just me” when installing Python RHI packages.

Rhino doesn’t know how to load Python RHI packages that have been installed for “all users”. As of Rhino 6 SR6 (released June 2018), the Rhino Installer Engine will disable the “all users” radio button if it detects that it’s installing a Python RHI.

Thanks @will, I knew I was doing something wrong. Might be worth updating the guidance web page to include that important piece of info.

All working now.

Good idea. I’ve added a warning to the Rhino 5 developer docs :+1:.