Setting type hints in a Python component

Hey everyone,

I’m trying to specify the type hints of Python. So far I got to the point where I can access the type hint information with:

ghenv.Component.Params.Input[0].TypeHint

Which holds a GhPython.Component.GhDocGuidHint object. How do I choose the GhPython.Component.GhDocGuidHint so it becomes the type hint I want?

Cheers!
Christian

Hi Christian

if you are attempting this from a scripting component, this won’t work. You must do this from an external (outside-of-solution-time) dialog or ‘moment’.

Can you tell more about the problem or issue you are trying to solve?

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Giulio,

I’m trying to make a component that packs a mesh into a dict, together with some data, then sends it to a second component which unpacks and joins the mesh.

To join the meshes I’m using:

import rhinoscriptsyntax as rs
rs.JoinMesh(meshes)

In the first component, where the dict are packed, the meshes are transformed with:

rs.coercemesh(mesh)

before they are send to the next component.

If I don’t transform them, then JoinMesh won’t work.
If I don’t set the type hints to mesh then JoinMesh returns None.

I have attached a gh file with the components: Type hints.gh (7.0 KB)

/Christian

Hi Christian,

this is how you should set-up this type of exchange through custom classes:

passing_types.gh (24.4 KB)

You should just check the right type hint. This is not a Python requirement, this is so that your script works correctly with the rest of Grasshopper.

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com