Grasshopper

algorithmic modeling for Rhino

Hello everyone,

I just start to play with the ghpython Node-In-Code Method.

Found that for some ghcomp like 'SurfaceClosestPoint' I cannot extract the 'uvP' output.

Is there any mistake I made in the code?

I guess it is the issue of the space within the output name.

If yes, is there anyway that I can simply ask for the second output from the ghcomp instead of typing the output name?

Attached image and GH definition shows the problem.

Thanks for you help in advance.

Cheers,

Jack

Node-in-Code%20Q.JPG

Node-in-Code%20Q.gh

Views: 1064

Attachments:

Replies to This Discussion

Wowwww~~Cooooool~~

Thank you djordje!!

That's great!!

I try the first way and it works!!

But don't know why the easier way is not working..

Did I miss something?

Thanks,

Jack

Attachments:

I made a typo, sorry. Just remove the "dot" from the end.

Ah, Ok, it works now.

Thanks Djordje!

Hi Jack.

ghpythonlib.components functions still do not have the same names as Grasshopper component outputs.
That is something Mcneel guys will work on in the next few releases.
The way you could see the output names, is to print what an actual function returns:

A = ghcomp.SurfaceClosestPoint(P,S)
print A

 # results in:

Output(point=[<Rhino.Geometry.Point3d object at 0x0000000000000043 [-10.410854385947,-20.6284439983629,2.80581405863778]>, <Rhino.Geometry.Point3d object at 0x0000000000000044 [12.8304213273372,-31.7258031570232,2.37724613905609]>, <Rhino.Geometry.Point3d object at 0x0000000000000045 [-7.2608089490807,-36.1941926500218,1.96016166446665]>], _1=[<Rhino.Geometry.Point3d object at 0x0000000000000046 [0.318234538833558,0.846936848591264,0]>, <Rhino.Geometry.Point3d object at 0x0000000000000047 [0.858879239911428,0.448029981466632,0]>, <Rhino.Geometry.Point3d object at 0x0000000000000048 [0.391411890138304,0.285050946668576,0]>], distance=[1.8392227315797936, 7.303755781978618, 1.9773264160602087])

The bolded ones are output names. So in your case "uvP: would be "_1".

There's an easier way: just require a certain element from the tuple which function returns:

#P:
A = ghcomp.SurfaceClosestPoint(P,S)[0]
 #uvP:
A = ghcomp.SurfaceClosestPoint(P,S)[1]
#D:
A = ghcomp.SurfaceClosestPoint(P,S)[2]

Hi djordje,

I have another 'Node in Code' related question(please forgive me if you think I am too lazy to start a new thread).

I tried to do a straight loft in ghpython but cannot achieve it.

I tried both ways, pass the loft options from the external input and from the internal script.

neither of them work.

Could you help to have a look at my script(it is very short :)

Cheers,

Jack 

Attachments:

Hi Jack,

Not sure really.
I haven't been checking the LoftOptions function inside of ghpython.
It probably has something to do with "Type hint" of your "O" input plug. Try changing it to something else ("string" or maybe "surface"?).

I the end: there are limitations to ghcomp functions, so not all of the them could be replicated with grasshopper components. The Mcneel folks are will try to improve this for the next releases.

Hi djordje,

I have tried all the type hint but they all doesn't work..

But it is ok, maybe I should try some rhino command.

It is good to know the limitation though.

Thanks djordje.

Jack

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service