I tested GhPython in WIP 7.0.19176.14015 (06/25/2019) and indeed the ‘Input is path’ option is present and I’m able to execute a script, but how do I get access to the input and output variables?
Hi Florian @frist,
you should type, in the .py file, the same things you would type in the GhPython editor. Where is the confusion coming from?
for Robert McNeel & Associates
no unfortunately that is not working.
Here is my test:
The embedded script works as expected, it can access the input ‘myStr’.
The script streamt from a file in the old way works as expected.
The script given by filename in the new way does is executed, but not have access to the GhPython inputs and outputs.
I’m I missing something?
yes I see the problem. I’ll try to have it fixed by Tuesday, when the next WIP should go out.
for Robert McNeel & Associates
I’ll try to have it fixed by Tuesday
If you really find the time to work on the problem, could you briefly explain how you solved it? I’d be interested because right no I do not see a nice solution.
One quick fix of course is to load the file and use the ExecuteScript to execute the script, but that would not solve the debugging issue.
The only thing I can think of is to use ExecuteScript to execute something like this:
import __builtin__ __builtin__.myStr=myStr import importlib extSript=importlib.import_module("test.py", package=None) reload(extSript)
This gives test.py access to myStr, but it seems like a dirty hack (and I’m not even sure it how this would look like for outputs).
I am adding a new method to ScriptScope:
You are right: with the previous method it would not work.
I tested the latest WIP version and it work as expected now. This is a really nice feature as it allows to edit and debug GhPython scripts in an external IDE. I’m using Visual Studio 2019 but, VS Code, Eclipse or any other IDE would work just as fine.
Any chance you guys could collaborate on a step by step guide to setting things up to edit and debug GhPython scripts in Visual Studio? Great if it could end up in the Developer docs, too. I’ve read through this thread and looked elsewhere: the info may all be there, but if it is, it’s scattered and hiding from me!
Any chance you guys could collaborate on a step by step guide to setting things up to edit and debug GhPython scripts in Visual Studio?
Sure, I already had two requests buy other people, and I started working on a detailed step by step guide, but I did not find the time to finish it. But it’s still on my to do list.
I also heard that @DavidLeon was going to write something for the Dev Docs. I think he is on vacation this week, though.
I’ve added a step-by-step guide on how to make this work in the DevDocs.
Thanks for the Guide! However, following the set up procedure (with Visual Studio 2017), I get the following error when I try to use the component:
Edit: FYI after installing the latest build of the WIP the error message no longer appears and the component runs.
I have to run the “Attach to process” step each time I start a new GH session: is there a way to make the settings stick to the VS project?
@jeremy5 if you have already attached once in the VS session you can quickly attach again with Debug > Reattach to Process (Shift + Alt + P)
Is that what you are looking for?
Thanks, that is helpful, but I would like to be able to make the setting sticky between sessions. Typing the string is hardly onerous so the question doesn’t warrant effort, but this would be a small nicety, should anyone already know the answer.
I don’t suppose this can be made to work in V6? The “Input as Path” option doesn’t exist.
It cannot, sorry.
A post was split to a new topic: Problems connecting to VS2019 debugger from Python