The colour of a sphere
-
Merry Christmas!
How I can assign a color (material) to sphere?
I know this variant:
circle1 = entities.add_circle([0, 0, 0],[0,0,1],15,24)
circle2 = entities.add_circle([15,0, 0],[1,0,0],15,24)
face = entities.add_face(circle1)
face.material="yellow"
face.followme(circle2)
entities.erase_entities circle2It works, but I would like to avoid the line <face.material="yellow">
and assign the material not to face but to the sphere shape as a whole after followme action.Is it possible?
-
@alr said:
Merry Christmas!
How I can assign a color (material) to sphere?
I know this variant:
circle1 = entities.add_circle([0, 0, 0],[0,0,1],15,24)
circle2 = entities.add_circle([15,0, 0],[1,0,0],15,24)
face = entities.add_face(circle1)
face.material="yellow"
face.followme(circle2)
entities.erase_entities circle2It works, but I would like to avoid the line <face.material="yellow">
and assign the material not to face but to the sphere shape as a whole after followme action.Is it possible?
That is probably the simplest way to wind up with a yellow sphere. Maybe what you want is to group the faces that makeup the sphere and then set the material on the group? If so add_group to entities and build the sphere in that group. Then do group.material="yellow".
-
@unknownuser said:
That is probably the simplest way to wind up with a yellow sphere. Maybe what you want is to group the faces that makeup the sphere and then set the material on the group? If so add_group to entities and build the sphere in that group. Then do group.material="yellow".
Thank you for your answer, but my real problem is the yellow edge around the yellow sphere [see FIG.1]. I have to use the mode Edges=On & Edges Color by Material according to my task.
When I use the common variant I have mentioned in my first post without line <face.material="yellow"> and AFTER this in Sketchup (not from RUBY) assign the yellow color to sphere surface I have needed result - the yellow sphere with BLACK Edge around - [see FIG.2] - but I have to obtain this result from the RUBY only.
When I use <face.material="yellow"> line - there is a yellow edge around yellow sphere [see FIG.1 again].
How add_groupe can help me in this case? How can I group only the surface without the edges from the Ruby? May be some example code?
-
group=Sketchup.active_model_active_entities.add_group entities=group.entities ### make the sphere a group - no danger of it sticking to some existing geometry... circle1=entities.add_circle([0, 0, 0],[0,0,1],15,24) circle2=entities.add_circle([15,0, 0],[1,0,0],15,24) face=entities.add_face(circle1) face.followme(circle2) entities.erase_entities(circle2) group.material="Yellow"
Group the sphere's parts and colour the group...
-
@unknownuser said:
Group the sphere's parts and colour the group...
Thank you for the answer, but I am afraid that the situation is not so simple. If you try this approach you will find the yellow edge around the sphere (as on the FIG.1 in my previous post) again . The reason is simple - the grouping combine not only surface elements but the edges as well.
You can see this effect if you set [Edges On] and [Edges Color by Material]. As I mentioned, I have to use this settings in my task.
Do you have some suggestions?
-
###group.material="Yellow"### i.e. you remove this bit of code and add this. entities.each{|e|e.material="Yellow" if e.typename=="Face"}
Only faces get to be yellow - edges stay unchanged...
-
It's work! You did it! Thank you very much!
I appreciate your assistance - it was a good lesson to me.
I was so stupid ...
Advertisement