I think this topic belongs to the Mac forum. I wonder if there is a nice solution for pythoneers on the Mac? Shouldn’t the new XCode work? (I haven’t done any Mac programming since I switched to MS just for Rhino.)
Unfortunately, you are digging a little into the ‘impossible’. @Alain has done some work to try and get remote debugging to work (debug from a separate application), but we don’t yet have a good solution on OSX. We do plan on writing an editor or figuring out how to work better with existing editors, but again this is a project that requires quite a bit of research and I’m not too sure where we are with respect to that research. I’m letting @Alain take the lead on that project
tbh, i don’t even know what remote debugging is supposed to offer
i just got sick of the process of getting the script to run in rhino to see if it works (and doing that process a hundred times an hour)… but so far, rhino seems to tell me where the errors are happening and in many cases, why it’s happening… so that’s sweet.
here’s a pretty ch_easy little workaround to the switching problem:
managing the files will need a decent game plan but i think if you have 2-3 files just for the switching/writing/copy&pasting/etc then using Duplicate(or other methods), put them in ‘real’ files when need be, it should work out ok…
Well, as you seem to be starting to script in earnest, you will soon really want to have a script editor with an integrated debugger function … The debugger allows you to stop the script at any chosen point (“breakpoints”) and look at the value of all your variables - which will help you figure out your errors very quickly in most cases. As in “Aha, my variable xxx is a string when it should be a list…” or “Hmm, this function is returning None, so it’s failing somehow, maybe I better see what’s happening there…”
At the Rhino reseller meeting in Barcelona they seemed to have found something that might work on the Mac side - an editor/ debugger is not something you write yourself, you adapt something that exists - but I don’t know how/when that might happen or if it will before release time - I hope so. That’s why I still develop in Windows and just run the script on Mac afterwards via a Dropbox folder as a final test.
yeah, i watched some videos and saw the built-in editor… i want that
the thing in the video is just a stop-gap solution until macRhino gains an editor (or capabilities to communicate with outside solutions)
i basically want to do 5 scripts… which would probably have a fair value of $500 each to outsource / customize to my liking… so i’ll view it as me paying 2500 for tuition (in the form of time etc) and learning how to write them myself
what happens after that, i don’t know but i’m pretty sure i’ll come up some other ideas for scripts after the initial ones are written.
oh… something else i found out with Xcode that’s pretty sweet…
you don’t even have to do what i showed in the video in order to get easier testing abilities… with xcode/python/rhino, you can have an open & unsaved document and the unsaved contents will be read when you run the script in rhino…
for example-> this works:
• make a blank python file (example.py) and place it in your rhino scripts folder
• open example.py in xCode
• type print "hello rhino" (do not save*)
• in rhino, use RunPythonScript then choose example.py
• “hello rhino” will be returned in rhino
*you can save if you want… just sayin, you don’t have to.
then you can go back to xcode, type some more stuff, not save, run the script in rhino again and the updates are read… it’s reading the unsaved file.
if you put a keyboard shortcut (like ⌘R) to ! -_RunPythonScript example, it becomes even easier to test the script.
or, the setup i’m using is with the service as outlined in the video in xcode… when set up this way, you can run the script from either rhino OR xcode… ⌘R in either application will trigger the script to run in the exact state it’s in… so, you don’t have to worry about which app has focus at the time of activating the script… honestly, it almost feels like you’re only in rhino when set up this way.
i tried it in quite a few editors and none worked this way except xcode… the only one which comes close is Chocolat which has the following preference setting:
so with that, you can type in the .py… then go to rhino-> activate the script and it will work since when you switched to rhino, the file saved automatically.
EDIT-- oh, i get it that if you’re on windows, this stuff probably seems a bit backwards and/or worse… but, if you’re on mac, it’s actually moving forward because at first glance, writing scripts on mac is pretty bad …these little tricks make it easier for now.
While a debugger surely is a great thing, I find myself rarely needing one when writing Python code (I mainly write directly in the Grasshopper Python editor, which is also very bare bones). I instead use the help() and dir() functions extensively for introspection of functions and objects.
Since you are using the RhinoScriptSyntax module this may not help as much as if you were implementing RhinoCommon directly (i.e. you are probably usually operating on GUIDs and not directly on geometry types).
That said, I would still recommend learning to use these functions. Especially since they are vanilla Python functions which can be called in any Python environment, never having to fly blind again
yes, as of now, i’m using GUIDs… and to be honest, i don’t know what you mean by “not directly on geometry types”.
regardless, i’ll check out the links and try the examples to see how it can help me.
on a side note, i found something simple that helps me immensely when manipulating planes… that being- temporarily add a plane surface via rs.AddPlaneSurface… at least then i can see what’s going on
(posting in case a python newb reads this later… it will probably help them out too)