Point cube

 Point Cube with custom attributes

Point cube definition

This sample script creates a simple cube with a series of points that control the amount by getting x,y,z maximum values. Colors are automatically generated depending on the coordenates. Use the bake? toogle to bake geometry with custom properties, and the calculate? one to control when to activate the component. You can always use the same code as snippets for wour own components.

#script written by Adolfo Nadal

#import rhinoscriptsyntax library

import rhinoscriptsyntax as rss


#IF NEEDED import also thino.geometry>Nurbs, 3dPoints.... native grasshopper geometry

import Rhino.Geometry as rg

#import these to MODIFY an object attibute when baking

#sc allows us to ADD objects to the model ->simulate a bake

#rd allows us to OBTAIN properties

#sd to "print" color

#Rhino to get the current document

import scriptcontext as sc

import Rhino.DocObjects as rd

import System.Drawing as sd

import Rhino






#create list for the output with THE SAME NAME AS THE OUTPUT IN THE COMPONENT

#this is an empty list > you need to add (append) objects to it

puntos = []


sc.doc = Rhino.RhinoDoc.ActiveDoc


#execute only if calculate is on (True)

if (calculate==True): 

    for i in range(nrPuntos):

        for j in range(nrPuntos1):

            for k in range(nrPuntos2):

                x = i

                y = j

                z = k


                pt = rg.Point3d(x,y,z)



                #use rg when changing object attributes, other wise fine



                    #add with attributes ->color

                    r = 255*(i/nrPuntos)

                    g = 0

                    b = 255-255*(k/nrPuntos2)

                    if(r>255) :

                        r = 255



                    #obtain attributes

                    attr = rd.ObjectAttributes()

                    attr.ColorSource = rd.ObjectColorSource.ColorFromObject

                    attr.ObjectColor = sd.Color.FromArgb(r,g,b)



Search Site

archi·o·logics survey

I am interested in: