sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    The colour of a sphere

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 975 Views 3 Watching
    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

      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

        @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

          @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
          • TIGT Offline
            TIG Moderator
            last edited by

            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

              @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
              • TIGT Offline
                TIG Moderator
                last edited by

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

                  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
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement