sketchucation logo sketchucation
    • Login
    1. Home
    2. nicoiweins
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    N
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 4
    • Groups 1

    nicoiweins

    @nicoiweins

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

    nicoiweins Unfollow Follow
    registered-users

    Latest posts made by nicoiweins

    • 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