I have a script that creates cylinders turns them into components and displays them, I then export an picture of the view. I would like to then change the color of the components faces and export it again to an image like so: File1 and File 2 attached
Any help is appreciated, thanks,
Mike
The script is as follows:
def createComp(compColor, yaxis)
normal_vector = Geom;;Vector3d.new(0,0,1)
radius = 0.5
center_point = Geom;;Point3d.new(yaxis,1,0)
mygroup = Sketchup.active_model.entities.add_group
myedgearray = mygroup.entities.add_circle center_point, normal_vector, radius
myfirst_edge = myedgearray[0]
myface = mygroup.entities.add_face(myedgearray)
myface.material = compColor
myface.pushpull(15)
return mygroup.to_component
end
# Get "handles" to our model and the Entities collection it contains.
model = Sketchup.active_model
entities = model.entities
cylinder1 = createComp("red", 1)
cylinder2 = createComp("white", 1)
cylinder3 = createComp("blue", 1)
for i in 1..10 do
transformation = Geom;;Transformation.new([0,i,0])
entities.add_instance(cylinder1.definition, transformation)
transformation2 = Geom;;Transformation.new([1,i,0])
entities.add_instance(cylinder2.definition, transformation2)
transformation3 = Geom;;Transformation.new([2,i,0])
entities.add_instance(cylinder3.definition, transformation3)
end
view = model.active_view
status = view.write_image "redwhiteblue.jpg"