Created
May 15, 2013 21:27
-
-
Save sbaer/5587540 to your computer and use it in GitHub Desktop.
Automate Rhino5 with IronPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following script is meant to be run inside of IronPython | |
# It demonstrates how to automate Rhino from a script | |
import System | |
# start an instance of Rhino | |
t = System.Type.GetTypeFromProgID("Rhino5.Application") | |
rhino = System.Activator.CreateInstance(t) | |
# show Rhino (optional) | |
rhino.Visible = True | |
# run your script or a bunch of scripts | |
rhino.RunScript("!-_RunPythonScript myscript.py", 1) | |
# shut down rhino | |
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rhino) |
probably it is a permission problem:
http://support.software602.com/kb/view.aspx?articleID=987
or a 32-64 bit problem:
http://stackoverflow.com/questions/9502040/80040154-class-not-registered-with-interop-from-asp-net
http://stackoverflow.com/questions/7197506/how-to-repair-comexception-error-80040154
Hi Goswin,
let t = System.Type.GetTypeFromProgID("Rhino5.Application")
let rhino = System.Activator.CreateInstance(t)
works for me and gives me a System.__ComObject
I didn't try to go further
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Steve,
Thanks for posting this.
I tried if the same would work with F# interactive from VS:
let t = System.Type.GetTypeFromProgID("Rhino5.Application")
let rhino = System.Activator.CreateInstance(t)
but I get this COM error on CreateInstance:
"..class not registered..." REGDB_E_CLASSNOTREG
do you have any idea if this can be fixed?
System.Runtime.InteropServices.COMException (0x80040154): Die COM-Klassenfactory für die Komponente mit CLSID {ECE2F51F-F374-4736-96E7-9DF182CCC178} konnte aufgrund des folgenden Fehlers nicht abgerufen werden: 80040154 Klasse nicht registriert (Ausnahme von HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
bei System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
bei System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
bei System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
bei System.Activator.CreateInstance(Type type, Boolean nonPublic)
bei System.Activator.CreateInstance(Type type)
bei <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\temp~vsA4EA.fsx:Zeile 3.