Grasshopper

algorithmic modeling for Rhino

Passing objects as class properties to another GHPython component

Hello!

Here my setup:

GHPython Component 01

- Class definition to create a tower of cones

- Cones are created inside the class definition, via rs.AddCone(...) command

- Cones are stored in a property of the class as a list

GHPython Component 02

- Received the tower objects created in the previous components as an input

- It reads the properties and outputs them without any issues

GHPython Component 03

- Received the tower objects as input

- I can read the GUIDs but can't do anything with the cones!

- When doing a rs.ObjectType(cone) through the cones, I get NoneType

How can I make component 03 work with my cones as geometry.? I want to, for example, extract isocurves from these cones. rs.ExtractIsocurves(...) returns me:

Runtime error (ValueErrorException): unable to convert ea727c25-1cbb-458c-9665-f5d26848e025 into Surface geometry

and rs.ExtractSurface(...) returns:

Runtime error (ValueErrorException): unable to convert ea727c25-1cbb-458c-9665-f5d26848e025 into Surface geometry

Any ideas on how to manipulate these cone geometries??

Thanks!!!
Daniel

Views: 1648

Replies to This Discussion

When using rhinoscriptsyntax functions you usually have to use Guids. You can set this manually by assigning type hints to your input parameters on the GHPython component like so: 

Right-click the input parameter -> Type Hint -> Select the one called "ghdoc object".

Hello Anders!

Thanks for the quick reply... I am using Guids... I have a list of cones as GUIDs. When I say:

>> print cones

[<System.Guid object at 0x00000000000006DD [7faf5bf4-37f7-4a4d-8c96-e50ba89d07c9]>, <System.Guid object at 0x00000000000006DE [7ae3e35f-02bf-42f6-a74c-c5087c1e578b]>, <System.Guid object at 0x00000000000006DF [07e8e363-56a1-476d-954f-96dfe227db91]>]

I get the right results... but when I do then

>>print cones[0]

7faf5bf4-37f7-4a4d-8c96-e50ba89d07c9

I get only this number. Which is exactly the number that is not being accepted by my next rhinoscriptsyntax commands...

What am I doing wrong??

Daniel

Hmm, that's a good question. I pretty much stick to straight up RhinoCommon at this point. Especially within GH Python components, which means that I never really have to deal with GUIDs unless if I'm referencing objects in the Rhino document directly in the code. Could you upload a file demonstrating this behaviour perhaps?

Hi Anders,

Attached is the file with those 3 definitions.

It is still a very rough sketch (don't mind the weird code!)

Most important is:

  • 01 created my "cone towers"
    • Line 62 is where I actually create the cones as a rs.AddCone command; would you use here Rhino.Geometry.Cone instead?
  • 02 is a simple output of parameters
    • here you see how the cone geometry is displayed with no problems when I get them from the tower.cones property
  • 03 is where i have trouble
    • Line 26-30 this does not work! It does not accept my Guids for anything
    • Line 41-42 shows how the guid is actually valid when I try to output one cones, for example

So you'd rather use commands from RhinoCommons instead of rhinoscriptsyntax to manipulate and create geometry?

Thanks !!!

Daniel

Attachments:

Hello,

I suppose you don't feed the print  output to the next python component, hence you are not trying to convert strings into guid or geometry or whatever.

if you manipulate the cones in the first component then the output is not guids anymore but IGH_goo geometry, so its not a guid and as a result cannot be handled by rhinoscript commands.

on the other hand it would help to preview some of the code.

M.

edit: +1 to Anders ''stick to straight up RhinoCommon'' 

 +1 to Anders ''stick to straight up RhinoCommon'' 

This is actually interesting, because I was actually confused as to when should I use rhinoscriptsyntax or RhinoCommon ... I'll try it out with RhinoCommon and see where I get to....

This actually makes my life a thousand times easier........

Not just easier, often times faster. Glad you got it working :)

Quick update... All works now. I followed the advice to use RhinoCommon and got rid of GUIDs altogether.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service