Grasshopper

algorithmic modeling for Rhino

Hi, everyone.

I haven't had trouble reusing and "translating" Python scripts to GHPython until now. The script is exactly the same with the exception of a conditional statement (see images and attached files).

The script imports a simple CSV file and adds points accordingly in a "for ..." loop. In the Python editor this works perfectly well, but when I brought it over to GHPython, it runs through the script and only outputs the last point. Is this something native to the Grasshopper environment? Am I missing something simple or "hidden in plain sight," so to speak? Below are images and attached are all the needed files.

Thanks in advance for taking the time to look at this.

Cheers,

/SPM

Views: 789

Attachments:

Replies are closed for this discussion.

Replies to This Discussion

Hi Stephen, I think the confusion arise from targeting the Rhino document versus targeting the Grasshopper document (there are quite a few threads on this topic). A few fixes:

1) When working in GHPython it's preferable to assign input variables as input parameters on the GHPython component. As opposed to calling functions in rhinoScriptSyntax for getting a string, filepath etc. You can use a FilePath parameter for this.

2) In the original script you simply add each "geoPt" to the Rhino document within your loop. To get all the your points as an output in Grasshopper you need to append them to a list which we then assign as an output parameter.

Hope that helps.

Attachments:

Anders,

Thank you for the detailed reply and taking the time to look at my file(s).

It's funny, I initially assigned the CSV variable as a GHPython input parameter, but I did not append the list, thinking that the loop would run through each item as it did in the Python Editor (as evidence by Grasshopper pulling the last item). So I switched back to the single boolean input for the purposes of this post. I suppose the "list.append" makes all the difference.

Much obliged.

/SPM

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service