3D_text color
-
Hi,
I am a real newbie when I comes to Sketchup and Ruby
I was introduced to Sketchup and Ruby last week.
I have been trying some of the tutorials, etc..., but I am (obviously) not really familiar with all details of the object model of Sketchup.
I have an issue with putting colored text on a face (of a cube or just a 2d square).
I can see the text, but applying a color or material to it, is not so obvious, as far as I can see (newbie
The only think I could find is applying material to each individual face of a 3d_text string. See code snippet at the end of the message.
I hope there is an easier and more importantly faster way to do this
All help is welcome
Kind regards,
Jan
` grp = ent.add_group
grp.entities.add_3d_text("My Labels", TextAlignCenter , "Verdana", false, false, 4.inch, 1.mm, 0, true, 1.mm)txtFaces = grp.entities.find_all{|f| f.is_a?(Sketchup::Face) }
for f in txtFaces
f.material=[0,0,255]
end #for`Running Sketchup 2014 make, windows 8.1
-
Hi Jan,
So SketchUp faces have a front and a back. Appling a material to the Face colors the face front only. use Face.back_material to set the back material.
In addition, when you create a Face on the XY plane, the Face faces down. In other words, the front of the face is facing down. If you look at the text from below, then you should see the blue side.
Also, you could have applied the material to the grp object.
Hope that helps.
-
@jim said:
Also, you could have applied the material to the grp object.
Yes, SketchUp entities have a default material of
nil
which means "unassigned, inherit from parent if possible."So set the grp material and SketchUp will display all the primitives in the group (whose material is unassigned,) using the group material.
Also a color and a material are two separate classes. (You can create a material using a color and/or a texture image.)
-
Jim/Dan,
Thanks for the reply.
Adding material (and back_material) to grp works for me.
Understanding why this happens is even better.
Advertisement