Python code arc through points by Mitch throws error in v7 solution?

Hi
@Helvetosaur

having successfully created button with StackObjectsAlongAxis.py by Mitch
referencing the path to the .py as suggested I try to avoid coding errors.

I then try for another

this AverageArcThruPoints throws an error.

AverageArcThruPoints3.py (3.2 KB)

What has caused this ?

What code do I need to make it work ?

Cheers

Steve

Look at your path… It has _Cancel in front of it…

Hi,
@Helvetosaur
I open the .py into notepad, search on word Cancel, nothing found.

The path to the .py file I cant see cancel in that.

Not sure what you refer to.

By referencing a supplied .py file I was told it avoids me doing any coding thats wrong, hence this.

But there is this _Cancel.

How did that get there and where is ‘there’ ?

Its like defusing a bomb this coding ! even when using coding ‘as is’.

Cheers
Steve

Maybe look at your own screenshots?

Open the button editor for the button you just created and take a screenshot of what it shows.
You also appear to have an extra space between the last backslash and the A in AverageArcThruPoints… I don’t know if that matters.

Hi,
here is my button editor.
I dont see in it Cancel.

the screenshot before was what rhino threw up when that button was run,.
so I need to find the Cancel that error refers to in the coding or path if thats what it ses and causes that error in the command line.

Floundering

Code makes me feel sea sick. days spent fiddling, not drawn a thing. weeks of PC rebuild still to do and work overdue.

Steve

This has nothing to do with “code”, this has to do with how you set up the button.

It should be like this:

! _-RunPythonScript (
<your full path to the script in quotes>
)

You don’t have the parentheses nor the ! plus a a space at the beginning.

If you set it up like that and it still doesn’t work, report back. And do take out that extra space in the path as I mentioned above, just in case. Plus make sure the script is really in the folder where you are pointing to.

Hi,
I was working to a post by Gijs in a thread

@Gijs
that said :-

1: Take one of your existing .py scripts, and place that in a location of choice, then make a button and put in what I suggested:

-_RunPythonScript “d:\script_directory\your_pythonscript.py”

and then post back if it works.

well it did, two buttons so far working… :grinning:

I just repeated the method,…
I took my path and file name and got:-

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

With this one I have now removed that gap, yes shouldnt be there.
I run it again, after relaunching rhino v7.
and now see this

I am again confused over which code is right as Gijs had that and you have the end with bracket one.

! _-RunPythonScript (
<your full path to the script in quotes>
)

I am typing out a final methods sheet but keep having to alter it !

Steve

@Helvetosaur without parenthesis it should also work, I do that all the time. But maybe it is cleaner to do it anyway?

@Steve1 when I get what you are facing, it is always a typo.
To test this, do this:

RunPythonScript
Browse to the script you want to run in your button.
Does it work? Yes? Then your path was wrong.

Dunno, I always run it with parentheses (habit from vb script days) and it always works, so that’s what I use.

Also corresponds with what’s on this page:
https://wiki.mcneel.com/rhino/macroscriptsetup

(OK, I wrote the page…) :stuck_out_tongue_winking_eye:

1 Like

We actually might need to give feedback when one tries to run a script and the script is not found, right now it just silently dies.

1 Like

Hi,

I do this and it runs. its very useful, nice tool Mitch.

However, that means I have a typo in my code.

and I dont know where, as I copied the address from properties of the .py code, then placed the .py file name on the end (and now have removed the erroneous gap)…

D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur

and file is

AverageArcThruPoints3.py

I have for code:-
-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

and pasting it here it doesn string it as one line but thats the forum window.

perhaps there is a way of pasting it ?

I will post this then look for Helvetosaurs recent method and try that.

‘’‘python-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”’‘’

um, that didnt work, three backticks name of code paste code three backticks.

I have a ’ under the @ symbol, I have nothing else. and is -_RunPyth etc etc the python code ?

Steve

Yes, good idea.

@Gijs
@Helvetosaur
so what is wonky with that code of mine to now give error


when it runs ok in RunPythonScript.

I cant see a typo anywhere.

Steve

To accurately copy the file path to a folder:
Browse to the folder in Windows Explorer. In the title bar you have the path in the form of
Bla > Bla > Bla > Etc.
Click once in the empty space next to it, and the path will turn into the classic
Bla\Bla\Bla\Etc.
and the whole path be highlighted. Ctrl+C and then paste it where you need.

Hi
@Gijs
@Helvetosaur
Doing that I get:-

D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur

and obviously we then add \ and the filename
AverageArcThruPoints3.py

D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py

which is what I have.

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins an
d Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

with enter key in middle of word ‘and’ to suss the address better as no means of reducing font size.

Can one post this as a scrollable line ?..how ?

I have then tried the ( ) method, (" and ") instead of " " doesnt do anything button dead.

( instead of " and ) instead of " sees command run ! and no errors.

so ( ) method is better, though my prior butons worked with " ".

Steve

Yes. Do the same thing as for code blocks posted in the other thread, 3 backticks, new line with your path, new line with 3 more backticks.

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

Note you have a straight quote at the beginning of the path and a curly quote at the end.

@Steve1 paste this in your button, it should work:

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py"

as Mitch mentioned, curly quotes are a no go

-_RunPythonScript “D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py”

-_RunPythonScript "D:\RHINO 3D WORK AND ASSOC FILES\Plug-ins and Scripts\AverageArcThroughPoints Helvetosaur\AverageArcThruPoints3.py" 

backticks from button to left of 1, with them on separate lines to code essential, thanks

( ) safer way makes the code work.

Steve