sketchucation logo sketchucation
    • Login
    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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Transformation scale

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 1 Posters 309 Views 1 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.
    • P Offline
      Pout
      last edited by

      Here is what i want to do:
      Scale an object in Z

      Seems simple but the whole points-geometry-transformation thing is not always very clear to me
      I know if i want to scale the first selected object 50% in z then this is the code:

      new_transformation=Geom;;Transformation.scaling thepoint,1,1,0.5
      select[0].transformation=new_transformation
      

      Now, thepoint, should be the base point of scaling (I think). Which should be the center point of the bottom face of the bounding box.
      I found this script to determine the center point of the top face of the bounding box:

      bb = Geom;;BoundingBox.new
      bb.add(select[0].bounds) if select[0].respond_to?("bounds")
      xmin=bb.min.x;ymin=bb.min.y;xmax=bb.max.x
      ymax=bb.max.y;zmin=bb.min.z;zmax=bb.max.z
      apex=Geom.linear_combination(0.5,[xmin,ymin,zmax+2],0.5,[xmax,ymax,zmax+2])
      

      Credits to who-ever wrote this!

      When I use that I suspect the entity should be scaled 50% upwards (since i use the top center point) and that the entity stays on the same spot.
      But somehow it moves to the origin. (with the 50% upwards scaling)
      What don't I understand?
      beforescaling.png
      afterscaling.png

      1 Reply Last reply Reply Quote 0
      • P Offline
        Pout
        last edited by

        ok i've found it here: http://forums.sketchucation.com/viewtopic.php?f=180&t=24947&p=213942

        use .transform! instead of .transformation
        .transform adds the specified transformation to the already existing one
        .transformation replaces the current transformation (like in: will put the object back to 0,0,0)

        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