Hi there,

Below is a portion of script our company has been using for many years in Rhino 4.0 without problem.  However, in Rhino 5.0, the first line of the below always returns a 'False' value, and my script exits.

When I enter -loadscript in as a command manually in rhino, it prompts me for the script name, and appears to load this correctly.

When I run this with the echo enabled, i don't see any line stating which script has been has been loaded, and if I add a line with "Rhino.Print strLoad" immediately following the first, this returns a 'false' every time.

The help file for the Rhino.Command method does not appear to have been changed from that from Monkey in Rhino 4.0, so I don't think there have been any changes to the way that this method is implemented. However, there is no example of how to implement this method in the way i have been using it.

I suspect that the .rvb file that I am calling is not being loaded, and I suspect that this is because  there is an undocumented change (or bug?) somewhere in either the Rhino.Command method, or the loadscript command, in Rhino 5.0. Can anyone shed some light on why this may be?

Many thanks! 

 

strLoad = Rhino.Command("-_LoadScript ""\\Reference2\reference files\CAD Library Files\Rhino Standards\Rhino Scripts\ReadShipInfo.rvb""", False)
 
 If strLoad = False Then
  Rhino.MessageBox "The ShipInfo.txt file failed to load. Please ensure it exists & then retry."
  Exit Sub
 ElseIf strLoad = Null Then
  Rhino.MessageBox "An error has occured loading ShipInfo.txt"
  Exit Sub
 ElseIf strLoad = True Then
 End If

Tags: Loadscript, Rhino.Command'

Views: 850

Replies to This Discussion

Hi Iain,

I am not able to to repeat that you are seeing. Trying running the attach TestLoadScript.rvb routine - you will need to modify it to point to the correct path of Hello.rvb.

On a side note, you probably should not be scripting the LoadScript command while a script is running. Although it seems to work in some cases, I've seen cases where you can get some odd behavior. 

Instead of calling LoadScript from your script, you might try using the "Include" subroutine found at the bottom of this page:

https://github.com/mcneel/rhinoscript/blob/master/ScriptUtilities.rvb

 -- Dale

Attachments:

Hi Dale,

Thanks for responding. I tried the TestLoadScript.rvb & Hello.rvb, and got the following back from Rhino in the command line (I deleted the ", false" from the end of the Rhino.Command line):

 

Command: -_Loadscript

Script file to load ( List ): "TestLoadScript.rvb"

Script file to load ( List ): _-LoadScript

Rhino.Command returned False

 

The first -_Loadscript is from the loadscript in my toolbar button - you can see the response where it asks for the script name in the second line, and the file name is entered from the loadscript command. Here is my toolbar button command: -_Loadscript "TestLoadScript.rvb"

The third line is the loadscript command from TestLoadScript.rvb - there is no line asking for the script name, and no indication the script is loaded. The last line is the response from the blnResult, indicating that the loadscript command (or the Rhino.Command) failed.

I'll look into the 'Include' subroutine too. My other option is to use two loadscript commands in my toolbar button (first to call Hello.rvb, the second to call TestLoadScript.rvb), but this is a little less efficient. Or i could put the hello.rvb into the startup scripts list, but again this is more complicated especially if i want to call other scripts or change the names of scripts. I'm working with in an office of over 50 users, so want the simplest solution possible.

Many thanks,

Iain

Hi Dale,

I just tried the include method you suggested. I've attached my code to read the same Hello.rvb (though I've renamed mine to Hello2.rvb as I have another Hello.rvb already).

I was getting an undeclared variable 'IsString' error with the If IsString(strFile/Path) lines so I took those out. The output in the Rhino command line is as follows:

 

Command: -_Loadscript

Script file to load ( List ): "TestLoadScript2.rvb"

Error including C:\Users\mill\Documents\Rhino\Rhino Scripts V5.0\Hello2.rvb"

 

I get the same result in Rhino v4.0 and v5.0.

Iain

Attachments:

The error is due to the file system object not being able to open the text file. Check closely the path you pass to OpenTextFile.

 -- Dale

Rhino didn't like the Chr(34) at either end of the path. I guess that put a double set of quotes around the path? Anyway, it works when I remove those and leave just a single set of quotes around the path.

Thanks,

Iain

You only need to surround a path string with double-quote characters when you script Rhino commands that want path strings.

RSS

Translate

© 2014   Created by McNeel Admin.

Badges  |  Report an Issue  |  Terms of Service