Error with CopyVector command in Rhino script - Need help troubleshooting

Hello everyone,

I have a .rvb file that contains a script for Rhino, but I’m encountering an error on the command line with “CopyVector” that I don’t know how to resolve. I’m a beginner and I inherited this code from a former colleague.

Does anyone have any suggestions on how I can troubleshoot this issue? Any help would be greatly appreciated. Thank you!
CreateCNCOffsetCurves_V4.rvb (23.4 KB)

Wow, that is a really old script created by… @DavidRutten !
It looks like it is calling another script “VectorMath” which you apparently don’t have…

Rhino.Command "-_LoadScript " & Chr(34) & "T:\Atelier\Rhinoceros\Scripts\Functions\VectorMath.rvb" & Chr(34), vbFalse

Function GetCurveOffsetPoint(strCurve, dblDistance, dblRatio, blnSide)
'This function returns a 3d point a specific distance (DBLDISTANCE)
'from a curve (STRCURVE) to a specific side (BLNSIDE) using the
'vectormath class (this has to be loaded into RhinoScript engine prior
'to running this function.

Exactly, David wrote the code. I’m a begginer so I struggle to understand how to debugg this code.
Firt of all, thank you for your reply and help.

So i’ve changed that line to:
Rhino.Command "-_LoadScript " & Chr(34) & “P:\Affaires\Atelier\Rhinoceros\Scripts_Classes\Functions\VectorMath.rvb” & Chr(34), vbFalse
Rhino.Prompt “Parsing CNC path structures…”

But I still have the same issue, i don’t know if i’m doing it correctly.
VectorMath.rvb (11.2 KB)

I tried to internalize the 4 needed functions from VectorMath in CreateCNCOffsetCurves so that the import of VectorMath is not needed. I have no idea if it will actually work that way…

CreateCNCOffsetCurves_V4EX.rvb (24.9 KB)

Thank u so much! I found another error in the code, the file path for the Loader.exe has changed.

So I tried your script and I had these two errors that i have no clue what it is about. Do u have an idea?

Yep, looks like I forgot at least one function from VectorMath, hang on…

Hmm, no, looks like it is there. For the first one, line 484 uses a vector that has come through CopyVector() a couple of lines earlier which should work… Something may be wrong elsewhere, really no idea. Would need an example file to test.

The other error VB6FR.DLL may be related to you running in French and there is maybe a .dll missing… Have you tried running the script with Rhino in English?

I’ve put Rhino in English but I have the same error.
This script worked few months ago, but we changed servers and the path changed, since the scipt fails.

To test the script, I’ve attached a .3dm file (with Loader.exe and VectorMaths.rvb)
CNC_Offsets.7z (183.4 KB)
, just need to select the curves and it is supposed to work.

Thank you very much Helvetosaur for your help. I feel that a made a step forwards thanks to you

Well, this is what I see:

datT is a vector - the curve tangent - which in VB is simply an array of 3 values - (x, y, z) like a point.

On the other hand vecT is an array of only two values, I guess that might be valid still, if it assumes Z is 0 (I don’t know, in Python this would not be allowed)

vecV is a copy of vecT, that works

However, then it asks for:
vecV(1)(0) = vecV(0)(0)

but vecV is a simple single dimensional array of two values:
vecV(0) = -0.244866804482109
vecV(1) = -0.969556727614594

and this is looking for a nested array - i.e. the first parens represents the first level and the second parens the second level (0)(1) so,

vecV(1)(0) does not exist
vecV(0)(0) does not exist

and hence it errors out at this point with a “Type Mismatch” - looking for a nested array and got a simple one instead. I don’t know how this ever worked, but perhaps in previous versions it simply ignored the second erroneous level… No idea really.

The thing is, that this script was probably written for Rhino 3 and all that vector math stuff was not yet available in Rhinoscript (it is now). In addition, there are perhaps some Rhinoscript methods that have changed since.

1 Like

So I tried the script in Rhino 3 (with the path changes) and by miracle it works !
Thank you so much Helvetosaur for your help!