sketchucation logo sketchucation
    • Login
    1. Home
    2. nicoiweins
    3. Posts
    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
    N
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 4
    • Groups 1

    Posts

    Recent Best Controversial
    • Glue a text to a face in ruby

      Hi,

      I would like to reproduce the text tool with the Ruby API

      I am able to select a face, to get its center, to generate a text with an arrow pointing this center point but when I move the text the point moves too. I would like the point to stay connected to the center of my face (like using the native sketchup text tool)
      I do not want to group the text and the face, I would like the same behaviour than the original tool

      Any idea?

      model=Sketchup.active_model
      ents=model.active_entities
      sel=model.selection
      vec=[10,10,10]
      sel.each{|el|    
        if el.is_a? Sketchup;;Face
          bbox = el.bounds
          point = bbox.center
          tt = "Her I am"
          txt=ents.add_text(tt,point,vec)    
      	end
      }
      
      posted in Developers' Forum
      N
      nicoiweins
    • RE: Ruby : Get dimensions of a transformed element

      Thank you TIG for your help

      I wrote this function

      def getLength pt1,pt2,myGroup
        myLength =  (pt1.transform(myGroup.transformation).vector_to(pt2.transform(myGroup.transformation))).length
        return myLength 
      end
      
      #    # for the boundingbox of the group myGroup
      #    width = getLongueur bbox.corner(0),bbox.corner(1),myGroup
      #    depth = getLongueur bbox.corner(0),bbox.corner(2),monGroup
      #    height = getLongueur bbox.corner(0),bbox.corner(4),monGroup
      
      #    # for a edge myEdge of the group myGroup
      #    length = getLongueur myEdge.start.position,myEdge.end.position,myGroup
      
      
      posted in Developers' Forum
      N
      nicoiweins
    • RE: Ruby : Get dimensions of a transformed element

      OK it seems great and for a bounding box?

      posted in Developers' Forum
      N
      nicoiweins
    • Ruby : Get dimensions of a transformed element

      Hi there,

      I have a problem with dimensions of a group which has been transformed with the scale tool
      (or the edges of a group)

      before and after the transformation, I get the same dimensions.

      here is my script :

      myEdges= []
      entGroup = myGroup.entities
      entGroup .each do |e|
        if e.is_a? Sketchup;;Edge
          myEdges<< e.length
        end
      end
      puts myEdges
      

      Is there a better way to get my dimensions using Ruby?

      using boundingbox I have the same problem

      bbox = myGroup.local_bounds
      widthBox = bbox.width
      depthBox = bbox.depth
      heightBox = bbox.height
      

      Thanks for your help

      Nicolas

      posted in Developers' Forum
      N
      nicoiweins
    • 1 / 1