Hello, I fail to remember how to display a simple vector with python in grasshopper ?
So what’s wrong with this code ?
nothing appear in my viewport where it’s supposed to be
import ghpythonlib.components as gh
import Rhino.Geometry as r
Here my tinny bug linked in the gh file.
thx for any help.
import rhinoscriptsyntax as rs
import Rhino.Geometry as rh
import ghpythonlib.components as gh
import math
ab1,ab2 = gh.Volume(x)
ab1 = math.floor(ab1)
ab3 = “Volume= “+str(ab1/100)+” Units”
print(ab3)
a = gh.TextTag(ab2,ab3,[255,255,255])
b = ab1
c = ab2
I thx for your answer, I use rh6 and I’m not used with the ghlib, i will wait and see a probable answer from @piac, beyond that the ghpythonlib is designed to be be user friendly and there what is happening is not intuitive at all (for me) so may be we are going to see more trough this in few hours.
ghpythonlib is a library that allows to use Grasshopper geometry functionality as a simple functions.
This is intuitively also its limitation: only components that act as pure functions work. If they work for other side effects or purposes (like looping, in Galapagos, or like the Timer, for expiring, or Vector/Text display, for displaying things without returning anything) there will be no useful way to use them.
When available they will actually run, but they run in their own Cluster and nothing will appear.
I personally would suggest to use this functionality to simplify big definitions, or create reusable functions. I would just use normal components for vector display or text tag.
Thanks
Giulio
–
Giulio Piacentino
for Robert McNeel & Associates giulio@mcneel.com
One option I’ve been using since forever in GHPython is the CustomDisplay class. It’s pretty basic and comes with its own issues, but is generally quite functional for a lot of things. I’ve written some helper functions I can share to work around some of the issues, if need be.
Every things is think for a specific use, and there no real need to go further following my need thx @piac for your quick feed back AndersDeleuran thx anyway.
Yes, but it’s really an implementation detail, and therefore it’s subject to change. Right now, slightly simplifying, a normal component is placed in a special solution that is not presented in the UI, it’s assigned values and the solution is solved. Then the results are harvested and given as function results. In addition there are some considerations for threading, for Grasshopper DataTrees and for performance in the mix.
Oh, so kinda creating a .gh file in the memory containing the desired component with the available inputs as a binary stream then save it and serialize the output and deserialize it inside the script?