Before getting into RhinoCommon, there is a step to get trained before going through the main ambiance of high-frequency coding experience with thousands of classes, methods, and properties. Rhinoscriptsyntax is a scalar format of RhinoCommon.DLL which is useful to learn to do simple tasks all based on limited functions. While we work with objects by methods dedicated to and attributes attached to them, in rhinoscriptsyntax we use GUIDs instead. GUID is an acronym for “Globally Unique Identifier”. It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies and in Rhino we have access to .NET since the whole API has been based upon it too. Rhinoscriptsyntax also gives us working with commands, Doc Objects where we need to work with our running rhino files windows, and app methods where it could be found in the sample have been prepared for detailed inspection.
The code below is presenting a sample of using just Rhinoscriptsyntax directly to have cubic tessellation based on a randomized seed. The process could be set as phase one a 3D cellular automata where generating modular objects is controlled by specific functions. This code generates cubic modules in the 6-Axis direction list: [x, y, z, -x, -y, -z]. Every iteration also comes up with a new cube from a random selection of this list. First, we used a def in python as a function to generate what we want, and then it goes to select the next cube position in 3Dimensional space. This is just a very first step of what rhinoscriptsyntax gives us. You can develop this example by rebuilding the main generator where we might have our cubes in specific points instead of using randomization.
import rhinoscriptsyntax as rs import ghpythonlib.components as ghc import random as rd import time #-----Main Definition def Box(pt): Boxes = [] Boxes.append(rs.AddBox([pt, (pt.X, pt.Y+1, pt.Z), (pt.X-1, pt.Y+1, pt.Z), (pt.X-1, pt.Y, pt.Z), (pt.X, pt.Y, pt.Z+1), (pt.X, pt.Y+1, pt.Z+1), (pt.X-1, pt.Y+1, pt.Z+1), (pt.X-1, pt.Y, pt.Z+1)])) C_Points = [] C_Points.append(rs.AddPoint(pt.X-0.5, pt.Y+0.5, pt.Z+0.5)) return [Boxes, C_Points] #-----The Cordinates vec_z = rs.CreateVector(0,0,Vector) vec_y = rs.CreateVector(0,Vector,0) vec_x = rs.CreateVector(Vector,0,0) #vec_o = rs.CreateVector(0,0,Vector) #print type(vec_o) Cordinates_P = [] Cordinates_G = [] Cordinates_P.extend((vec_x, vec_y, vec_z)) Cordinates_G.extend((-vec_x, vec_x, vec_y, -vec_y, vec_z, -vec_z)) #print Cordinates #-----The Looper + The Translator Gen_Boxes = [] M_Boxes = [] Cords = [] Centers = [] rd.seed(Seed) if Start: first_box = Box(point)[0] i = 0 while i < Iteration: Rand_Cord = rd.sample(Cordinates_G, 1) Cords.extend(Rand_Cord) #Moving Boxes MovedBox = rs.MoveObject(Box(point)[0], Cords[i]) #Moving Centers MovedC_pt = rs.MoveObject(Box(point)[1], Cords[i]) #Outputs print "#{}: ({})".format(i , Cords[i]) MovedPoint = rs.MoveObject(point, Cords[i]) Centers.append(MovedC_pt) Gen_Boxes.append(MovedBox) i += 1 #print Cords #print Gen_Boxes #-----The Timer #-----Outputs points = Box(point)[1]