Grasshopper

algorithmic modeling for Rhino

Trying to Create and Set Color Attribute of Point via Python Component

I am having some trouble modifying attributes on a point object from the python editor. All the back and forth between rhinoscript and rhino common has me a little lost I think. The following code produced an error when it gets to the 'ObjectColor': 

"Runtime error (ArgumentTypeException): expected RhinoDoc, got GrasshopperDocument"

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

def ptGrid():
    #define output grid as a list
    gridDimX = x
    gridDimY = x

    #loop to define X limits
    for i in range(gridDimX):
        #loop to define Y limits
        for j in range(gridDimY):

            #Create a point at i, j

            gridPt = rs.AddPoint( (i,j,0) )

            rs.ObjectColor(gridPt, [0,0,0])


            #Append Point to Output
            zero.append(gridPt)

Thanks in advance if you can steer me in the right direction!

Views: 3307

Replies to This Discussion

Hi Tyler Crain

The rs.ObjectColor () function can not be used in Grasshopper,If you want to call the rs.ObjectColor () function in GhPython,You have to let ghdoc = Rhinodoc like this "sc.doc = rr.ActiveDoc".

If you just want to show the color of the point,You can use the AddPoint (Point3d, Color) method under the Rhino.Display.CustomDisplay (True) instance,like this.

I hope this help you.

                                                                                                              ——NARUTO

Attachments:

Thank you Naruto, this is extremely helpful, I'll try it out with the other pieces of script I am writing and see how it works all together.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service