RhinoApp.RunScript Not Blocking

Are there any known scenarios where calling RhinoApp.RunScript() would NOT be treated as a blocking call?

I am trying to do a scripted file import like so:

        // Import
        string importScript = string.Format(@"_-Import ""{0}"" _Enter", importPath);

        bool scriptSucceeded = RhinoApp.RunScript(importScript, false);

In this case I can tell by my breakpoints and subsequent code that the RunScript isn’t blocking and the code after this is executing immediately before my document is populated with the new objects. This is happening within a Rhino.Commands.Command which is decorated with the [CommandStyle(Style.ScriptRunner)] attribute.

I have been struggling with this all day and am getting no where. Any thoughts?

Hi Mike,

Any particular file format you are trying to import?

Yes, it’s a PDF containing some curves.

I’ve narrowed the problem down a bit more. It seems there’s an issue with the fact that I have a winform UI control that is being launched from my ScriptRunner command. The winform shared some variables with the command line options of my command. It seems that as long as I am only working with the command line options of my command then everything is golden but as soon as I touch my form it causes my RunScript to misbehave.

Is your UI modeless?

It is a non-modal dialog.

Hi Mike,

The attached sample seems to work here.

Try this:

1.) Build the sample
2.) Launch Rhino and use PlugInManager to install the plug-in.
3.) Put break points in SampleCsModelessTextForm.button1_Click and in SampleCsScriptableCommand.RunCommand.
4.) Run the SampleCsModelessFormCommand command.
5.) Pick the Import button. I’ve included a PDF file to test with.
6.) When your first break point is hit, keep pressing F10 to step over each statement.

You will eventually see the break point in the command hit. Continue pressing F10. When the command finishes, execution returns to the modeless form.

SampleCsModelessForm.zip (36.2 KB)

Does this help or am I confused?

Also, keep in mind RunScript returns Boolean indicating whether or not the command. If you want to know if the command ran successfully, you will need to watch for the OnEndCommand event and check the Result value.

– D