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

    Length conversion problems

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 120 Views 2 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.
    • T Offline
      thierry_st_malo
      last edited by

      Hi, all!
      As a first attempt at Ruby scripting in Sketchup 8.0, I have tried to emulate TBD's moveIT, but with one difference : the reference point is the group's or component's bounding box center, not the lower left corner.
      The logic is very simple and the thing works, but after the move the object is never quite at the intended position. There is always a slight difference. I suppose that it is a unit conversion problem, as I use meters and I believe that SU internally uses inches.
      How can I fix that? Thanks in advance,
      Thierry

      P.S: The script is attached if you want to look at it.


      V3DTools.zip

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        When you get the point's p.x etc it's returned as a Length - it's in inches.
        However the UI displays in an input box dialog in the current SKP's units, which could be inches or could be meters or whatever...
        To 'display' it in say the Ruby Console in meters use p.x.to_m - it's then a Float [in meters].
        When you type a value in an input dialog in 'meters' it will get converted discreetly into inches for Sketchup to use internally anyway...
        You don't need to worry about changing units in your code...
        The fact that the returned value is internally in 'inches' doesn't matter - the Length class allows you to manipulate it as if it were a Float and say divide by 2, or adding a value in inches to one 'seen' in meters in of no consequence.

        By the way... .rb files can be attached directly without zipping them...

        TIG

        1 Reply Last reply Reply Quote 0
        • T Offline
          thierry_st_malo
          last edited by

          Thanks very much, TIG 😍

          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