sketchucation logo sketchucation
    • Login
    1. Home
    2. mjones
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Groups 1

    mjones

    @mjones

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    mjones Unfollow Follow
    registered-users

    Latest posts made by mjones

    • Change face color of component

      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"
      
      

      File1


      File2

      posted in Developers' Forum
      M
      mjones