Difference Between Python for Rhino and Grashopper

Iwas trying to implement a simple script

import rhinoscriptsyntax as rs
import math
q = 15
for i in range (0,q):
for j in range(0,q):
for k in range (0,q):
a = rs.AddPoint(i,j,k)

and found variations .same script in Rhino py give me 3d point and when used in grasshopper give me just one point. why is that ???

hi Shridhar
Check the attached filepointlist.gh (2.0 KB)

1 Like

Hi Shridhar,

It’s because in RhinoPythonEditor each time you call a rs.AddPoint function a new point is added to the Rhino document, and each of those points is therefor visible in viewports. The same happens with your ghcomponent (rs.AddPoint function adds a point to the grasshopper document), but unlike Rhino, these points are not immediately visible. To make them visible you need to reference their guids or geometry to ghpython component output parameter (which is “a” in this case). What your script currently does is referencing only a guid of the last point.

import rhinoscriptsyntax as rs

a = []
q = 15
for i in range (0,q):
    for j in range(0,q):
        for k in range (0,q):
            a.append(rs.AddPoint(i,j,k))
2 Likes

Thank’s Guys.