• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

The colour of a sphere

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 3 Posters 974 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    alr
    last edited by 25 Dec 2007, 15:19

    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 circle2

    It 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?

    1 Reply Last reply Reply Quote 0
    • C Offline
      CPhillips
      last edited by 26 Dec 2007, 07:10

      @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 circle2

      It 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".

      1 Reply Last reply Reply Quote 0
      • A Offline
        alr
        last edited by 26 Dec 2007, 15:17

        @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?


        spheres.jpg

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 26 Dec 2007, 20:18

          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...

          TIG

          1 Reply Last reply Reply Quote 0
          • A Offline
            alr
            last edited by 27 Dec 2007, 05:24

            @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?

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 27 Dec 2007, 11:48

              ###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...

              TIG

              1 Reply Last reply Reply Quote 0
              • A Offline
                alr
                last edited by 27 Dec 2007, 19:54

                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 πŸ˜„ ...

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  5/7
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement