Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 6013

Creating an object from one layer onto another layer

$
0
0

@Christopher_Gornall wrote:

I am trying to add a sphere off of the two points I made but on a different layer. the new layer would be named Audio Evaluation. The dataset part of the script can be ignored, later on I will be using that to create the radius of the circle, but for now Just making the circle with a specific layer would be helpful.

thanks,
--Chris

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import math as ma


filename = 'import.csv'
folder = 'C:\\Users\\gornall72\\Desktop\\'


def raw_data():
    rawdata = []
    with open(folder+filename,'r') as infile:
        for line in infile:
            rawdata.append(line)

    dataset = []
    for data in rawdata:
        dataset.append(data.strip('\n').split(','))



    header_row = dataset.pop(0)
    data_array = []
    for i in range(len(dataset)):
        data_dict = {}
        for j in range(len(dataset[i])):
            data_dict[header_row[j]] = dataset[i][j]
        data_array.append(data_dict)
        print data_array
raw_data()


def Ballast_Points():

    search_string = "Ballast"

    for layer in sc.doc.Layers:

        if search_string.lower() in layer.Name.lower():

            for rh_obj in sc.doc.Objects.FindByLayer(layer):

                if rs.IsSurface(rh_obj.Id):

                    rc = rs.SurfaceAreaCentroid(rh_obj.Id)
                    if rc:

                        attr = Rhino.DocObjects.ObjectAttributes()
                        attr.LayerIndex = layer.LayerIndex
                        sc.doc.Objects.AddPoint(rc[0], attr)

                        #Brand =
                        #search_string = Brand

                        #rs.AddSphere(rc[0],Radius)

    sc.doc.Views.Redraw()




response=rs.MessageBox("Evaluate Classroom?",4)
if response!=7:
    Ballast_Points()
else:
    rs.MessageBox("Evaluation Aborted")

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6013

Trending Articles