as far as I know, the GHPython component doesn’t support the “preview” of a few types of objects, (text and hatches for sure…maybe some others?). @stevebaer or @piac would certainly know better. I believe the C# component does not have this limitation. Some info here:
You can bake the objects, (doesn’t solve your preview issue, but…), you could do something like: (note; I’m not certain if it’s best practice to put the sc.doc stuff in the function).
import rhinoscriptsyntax as rs
import scriptcontext as sc
sc.doc = Rhino.RhinoDoc.ActiveDoc
sc.doc = ghdoc
What do you mean? There is no intrinsic limitation. Free-floating hatches and similar have no preview in general. Grasshopper has no knowledge (does not especially “pass around”) hatches, does not visualize them, does not edit them. They are just like any external type. This is the same in C#. rhinoscriptsyntax functions that target these need to do their work in the Rhino document, but work also from GhPython.
Good point, my mistake. With that said, am I mistaken about the C# component being able to show previews of hatches/text, (when properly constructed with RhinoCommon, NOT rhinoscriptsyntax), where as the GHPython component does not? I must be conflating things…
Apologies for any misleading/out of context statements, thanks for clarifying!
hrmm, I have obvioulsy misunderstood something I thought I read…I thought it was something about the C# component’s inheritance of a display class, (or something close to that…), that the ghpython component did not. I am obviously incorrect and/or grossly misunderstanding. Upon further reading/research, it looks like there is a bit more to this than I simplified. Feel free to delete any of the above posts that are misleading/detracting.
also, ,thank you for all the info. I found this and it seems to describe a much simpler/direct logic.
The GhPython component was only imperative in V5. Now in V6, there’s the GH_Component mode that directly inherits from the Grasshopper SDK class, and that makes it possible to override some SDK methods. If required. That’s a very advanced and corner-case topic, really. Not geometry-related.
ghpythonlib is a module. That module was also Python-only. It allows to call into Grasshopper components as though they are functions. In V6, that functionality is also available in C# (in the NodeInCode namespace).