Dear friends,
Once again I need the Community’s support. I am reading a CSV file, creating three faces for each row of the CSV file. I want these three faces to be a single group. That is, I want one group for each line of the CSV file.
My code as is below, creates the faces but all faces for all rows of the CSV file are in the same group.
Apparently, I have not understood the involved hierarchies.
mod = Sketchup.active_model # Open model
ents = mod.entities # All entities in model
sel = mod.selection # Current selection
require 'sketchup.rb'
require 'csv'
#Load CSV panel and read
chosen_file=UI.openpanel("Open csv file", nil, "csv|*.csv||");0
lines=IO.readlines(chosen_file);0
lines.each{|line|
line.chomp!
next if line.empty?
xyz=line.split(",");0 # splits each row by comma
x_helio=xyz[0].to_f;0 #converts x to meters….the same for y_helio, z_helio, x1, y1,z1 etc
cyl_curve=ents.add_circle [x_helio.m, y_helio.m, z_helio.m],[0,0, -5], 3
cyl_face=ents.add_face cyl_curve
cyl_face.pushpull -1.9.m
cyl_face.material="Color1"
face1_curv=ents.add_face [[x1.m,y1.m,z1.m], [x2.m,y2.m,z2.m], [x3.m,y3.m,z3.m], [x4.m,y4.m,z4.m]]
face1_curv.pushpull 10
face_curv.material="Color2"
face2_curv=ents.add_face [[x1.m,y1.m,z1.m], [x2.m,y2.m,z2.m], [x3.m,y3.m,z3.m], [x4.m,y4.m,z4.m]]
face2_curv.pushpull -5
face2_curv.material="Color3"
face_group = ents.add_group ents.to_a
face_group.name = "I_am_Groot"
}
Thank you in advance.
Chris