I would like to compare the version of an installed plug-in (Python scripts, compiled into an RHI with the RhinoScriptCompiler) against that of an RHI that is sitting on my hard disk, but hasn’t been installed. Is this possible?
The only solution I have come up with is to use the file creation times, but checking the actual version string would be tidier, I reckon. Python’s distutils LooseVersion works nicely with the version string extracted from the plug-in’s path.
I opened the RHP (extracted from the RHI Zip) in a text editor, and found some human readable strings. However, the version (e.g. ‘1.0.5912.29706’) is not one of them.
Thanks for this, menno. Got the DLL props through the right-click menu, but the version shown is ‘1.0.0.0’. This is different to the version in the install path, which is ‘1.0.5912.29706’.
You can search for the string ‘Module’, and seek back by 74 characters. This is the first of four pairs of two bytes that you can convert to integers which give you the full Rhino plug-in version number.
I need to test this on more plug-ins to seek if the seek is always exactly 74 chars.
import System
assembly = 'C:\Program Files\Rhinoceros 5 (64-bit)\System\RhinoCommon.dll'
version = System.Reflection.Assembly.LoadFile(assembly).GetName().Version.ToString();
print version
Message: The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
But thank you for this tip. I didn’t know about this System.Reflection.Assembly thing. Very interesting.
Parsing the version from the RHP as I described above does work well:
with open(rhp_path, 'rb') as fh:
data = fh.read()
found = data.find('Module')
if found == -1:
print("Error: Could not determine version of '{p}' from DLL.".format(
p=rhp_path))
return False
fh.seek(found)
fh.seek(-74,1)
chars = fh.read(8)
pairs = []
for i in range(0, len(chars), 2):
pairs.append(chars[i+1] + chars[i])
hex = [ i.encode("hex") for i in pairs ]
ints = [ int(i, 16) for i in hex ]
ver_str = '.'.join(["{i}".format(i=i) for i in ints ])
I know the topic is old, but maybe someone will use this answer.
rhp is a zip, so just change extension from rhp to zip and extract content. Inside folder .rsrc you will find a text file version.txt with all the data you want including the VALUE “Assembly Version”