Components in ghpythonlib

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghc

e0 = ghc.Line(“0,0,0”, “10,10,0”)
e1 = ghc.Move(“0,0,0”, “0,0,10”)
e = ghc.Line_Pt(e0, e1)

ghc

Hello everybody,
could anyone tell me why these errors come back to me?
e0 and e1 are fine. e return error 2 of “Data conversion failed”

If you change your code to this:

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghc

e0 = ghc.Line("0,0,0", "10,10,0")
e1 = ghc.Move("0,0,0", "0,0,10")

print "e0 = {}, {}".format(e0, type(e0))
print "e1 = {}, {}".format(e1, type(e1))

e = ghc.Line_Pt(e0, e1)

You will get this output:

  e0 = 0,0,0,10,10,0, <type 'Line'>
  e1 = {'geometry': <Rhino.Geometry.Point3d object at 0x0000000000000090 [0,0,10]>, 'transform': <Rhino.Geometry.Transform object at 0x0000000000000091 [R0=(1,0,0,0), R1=(0,1,0,0), R2=(0,0,1,10), R3=(0,0,0,1)]>}, <class 'ghpythonlib.components.__namedtuple'>
  Warning: Line + Pt: input 2 point. error: Data conversion failed from Transform to Point
  Warning: Line + Pt: solver component. error: Data conversion failed from Transform to Point

You can see that your e1 variable holds a tuple containing a Point3d and a Transform object.

Now if you change your code to:

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghc

e0 = ghc.Line("0,0,0", "10,10,0")
e1 = ghc.Move("0,0,0", "0,0,10")

print "e0 = {}, {}".format(e0, type(e0))
print "e1 = {}, {}".format(e1, type(e1))

e = ghc.Line_Pt(e0, e1[0])
print "e = {}, {}".format(e, type(e))

You will get this output:

  e0 = 0,0,0,10,10,0, <type 'Line'>
  e1 = {'geometry': <Rhino.Geometry.Point3d object at 0x000000000000008E [0,0,10]>, 'transform': <Rhino.Geometry.Transform object at 0x000000000000008F [R0=(1,0,0,0), R1=(0,1,0,0), R2=(0,0,1,10), R3=(0,0,0,1)]>}, <class 'ghpythonlib.components.__namedtuple'>
  e = Origin=0,0,0 XAxis=0.707106781186547,0.707106781186547,0, YAxis=0,0,1, ZAxis=0.707106781186547,-0.707106781186547,0, <type 'Plane'>

Your e variable now contains a plane (I think this is your intended result).

I’m not sure why you’re trying to use ghpythonlib.components to do this. These things can be easily done with the RhinoCommon API methods which are pretty well documented here:
https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm

-Kevin

1 Like

thanks Kevin for the reply,

ghc2

sorry if I ask a second question:
the first three lines were used to be added to the fourth and I inserted the variables in place of the coordinates. as you can see from the message, the new problem concerns the fourth row of the BoundingBox, I did various tests and tried to solve it but without results. some idea?

yes indeed RhinoCommon would be more appropriate, but for me it is too broad a scope.
(I understand little or nothing)

I can use the rhinoscriptsyntax library just the basics
and I create some definitions in Grasshopper, then having discovered the ghpythonlib library, which via script simulates the functioning of Gh components, everything is more familiar to me. . . .

Difficult to help from a screen capture can you post a GH file?

What is the type and value of variable u?

From the error message it appears you are supplying a Guid where a Geometry input is required.

There are some functions in rhinoscriptsyntax for coercing Guid’s but without a GH file I can’t really help.

-Kevin

you are right Kevin, as these lines of code are part of a whole, I will try to extrapolate only the part of the code with a “closed curve” that replicates the same problem.

ps, however, the curve in question should not be a strange curve (which gives problems) being that before the code I made a small definition in Gh that works without problems, with the same curve etc. So through codes I follow the same reasoning and passages made with the def in gh (I repeat that it does not give problems)
the only doubt that comes to me now concerns the def in gh and that the BBox component, clicking with the right button in the center, has the option “Union Box” and I wonder if it is not necessary to set some options in indicating the first parameter of the closed curve in question? ? ? ?
thank you!

u = closed curve (Item Access / Type hint = ghdoc)
d = two point (List Access / Type hint = Point3d)

finally while I was looking for some solution, reading discussions I saw examples
of BBox with rhinoscriptsyntax, trying with this library no problem. mmmm :thinking: :thinking:

ps it seems that the ghpythonlib library works differently than rhinoscriptsyntax
(better to use it as little as possible)

thank you so much Kevin

From this post, I don’t think you can access these right-click options from ghpythonlib.components

Regarding the user of ghpythonlib, his recommendation is the same as what you wrote

-Kevin

Hi @kev.r

I did it!

after your last answer, I reread the whole discussion, and thinking back to your last considerations, it occurred to me to give it a try: change the parameters in the input of u = closed curve (List Access / Type hint = Curve) as soon as I did it everything was fine it works perfectly :muscle: ps luckily I have a hard head :laughing:
Thanks again :+1:

days ago I was trying to figure out how to set “List Access” via script but I couldn’t find the right examples
:sweat: