mcneel / ghpython

A Grasshopper component for Rhino.Python
http://www.food4rhino.com/project/ghpython
119 stars 34 forks source link

difficult namings in rhinopython document reference choice #27

Closed piac closed 12 years ago

piac commented 13 years ago

Modify some explanations based on this: http://www.grasshopper3d.com/forum/topics/this-call-is-not-supported-from-within-a-grasshopper-component?xg_source=msg_forum_cat

piac commented 13 years ago

Anyone's suggestions are welcome!

bengolder commented 12 years ago

I strongly agree that this is the single most confusing aspect of the plugin, and I'm not quite sure why it exists. In general, it seems like the Python component should behave in a manner similar to C# and VB.NET scripting components, neither of which rely on the user to make decisions about the namespace used by the script (unless they want to). I think comparing it to C# and VB.NET scripting components is a good guide to setting an interface standard for the ghpython component.

Do C# or VB.NET components automatically convert objects to ids and hook up to the document? If not, it seems like it should be something handled by the rhinoscriptsyntax library itself. It really seems like something that should be 'under the hood', and perhaps switched within a script, not within the component itself.

bengolder commented 12 years ago

perhaps a component scope variable can be set, such as: script_target = ghdoc script_target = rhinodoc

..and so on.

piac commented 12 years ago

Yes, the C# and Vb.Net scripting components do not support RhinoScript at all. Grasshopper by itself does not support RhinoScript either. So they are not really eligible for comparison here.

The scripting variable can be set within the script like this:

import Rhino
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc #sets the RhinoScript target to "Rhino document"
sc.doc = ghdoc #sets the RhinoScript target to "Grasshopper document"

About the "way" things are handed over, I'll try typing something to help the transition.

bengolder commented 12 years ago

Thanks Giulio!!

I see that the reason behind this is to be able to support RhinoScript, which is something that the GhPython component does alone, and which is one of its unique good aspects. I can now see why it makes sense to leave the doc as the default target.

I still think setting this variable is a confusion task to hand a beginner through the UI. Perhaps instead of having as a menu item, it could be set as a portion of default script.

In the C# and VB.Net components, there is a bunch of script text that is preset, partially editable, and collapsed. I think it might be helpful to have a similar division of space within the UI of the python scripting interface, and then variables could be set by a user within the script.

My hope in this is that it would hopefully address to cases:

If the text itself might seem like a bulky thing to include in the script editor interface, I think it would be very reasonable to leave it collapsed by default, along with some other useful import statements.

Thanks again.

bengolder commented 12 years ago

I'm not sure how this should interact with the id marshalling functionality, but I'm happy to help you think it over if you explain any dilemmas.

piac commented 12 years ago

There are no real dilemmas... It is really a question of whether it would be better to have a one-fit-all solution to obtain Guid as opposed to having roughly double the amount of "Hints", one each for geometry and the other for RhinoScriptSyntax guids. I'll see how it behaves with per-input-geometry/guids-choice, and then we can see if it works better.

About the copy-paste question: this is similar to the set up of hints in other components. Without these setups it is really hard to make the script work. Still: the point is very interesting.

piac commented 12 years ago

From 0.5 on there is no special "Mode" choice. Everything works as hints.

bengolder commented 12 years ago

fantatic! Thanks!