Individual (outside the Rhino) Python script throws error at lofting

Hello!

I would like to make an individual python script (witch I can invoke from command line without opening the Rhino). I’m using IntelliJ, and IronPython, for this, I added the RhinoCommon.dll by this way:

sys.path.append(r"C:\Program Files\Rhinoceros 5 (64-bit)\System")
clr.AddReferenceToFile("RhinoCommon.dll")

It work fine (I use more of the Rhino methods) until I call the Rhino.Geometry.Brep.CreateFromLoft method. It throw the next error:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at UnsafeNativeMethods.RHC_RhinoSdkLoft(IntPtr pCurves, Point3d start_point, Point3d end_point, Int32 loft_type, Int32 simplify_method, Int32 rebuild_point_count, Double refit_tolerance, Boolean bClosed, IntPtr pBreps)
at Rhino.Geometry.Brep.LoftHelper(IEnumerable1 curves, Point3d start, Point3d end, LoftType loftType, Int32 simplifyMethod, Int32 rebuildCount, Double refitTol, Boolean closed) at Rhino.Geometry.Brep.CreateFromLoft(IEnumerable1 curves, Point3d start, Point3d end, LoftType loftType, Boolean closed)
at Microsoft.Scripting.Interpreter.FuncCallInstruction6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) at Microsoft.Scripting.Interpreter.FuncCallInstruction10.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Compiler.Ast.CallExpression.Invoke5Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Compiler.PythonCallTargets.OriginalCallTarget7(PythonFunction function, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
at IronPython.Runtime.FunctionCaller1.Default6Call1(CallSite site, CodeContext context, Object func, T0 arg0) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Microsoft.Scripting.Interpreter.FuncCallInstruction6.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonCallTargets.OriginalCallTarget1(PythonFunction function, Object arg0)
at IronPython.Runtime.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0)
at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target)
at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)

and so on,…
I would like to make a script to generate remotely some meshes (exported to .obj, or something else). I tested my code inside the Rhino, it works (I don’t use rhinoscriptsyntax), but It throws the upper error outside the Rhino.

What should be the problem?
I hope you can help me!

RhinoCommon.dll is dependent on Rhino. That is, Rhino must be running in order for RhinoCommon.dll to be fully functional, as many RhinoCommon functions call back into Rhino.

Loft is a good example of functionality that is in core Rhino but exposed by RhinoCommon.

If you run your script from within Rhino, does it work?

Oh, I understand! Yes, it works fine in Rhino.
Could you help me, how could I make work it outside? Best way for me could be that the Rhino didn’t run, but if it is not possible, I can start it, and keep running for a while. How could I make that I call some script from command line (remotely), and Rhino do this, and it don’t close, and I call another script and so on.
I would like to make a web application, witch is a model configurator. I send the parameters to the server (here is the Rhino), it generates the model, export it to some tesselated 3d format (like .obj), and sent it to the client side.