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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Latitude/longitude not working ?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 402 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.
    • Didier BurD Offline
      Didier Bur
      last edited by

      Hi all,

      Has anyone ever got this working (out from the su-ruby api doc) ?

      Assuming you have set the georeference of your model in the Model Info dialog:

      coordinates = [10, 10, 10] # or whatever coordinate...
      model = Sketchup.active_model
      point = Geom;;Point3d.new(coordinates)
      latlong = model.point_to_latlong point
      latitude = latlong.latitude
      if (latitude)
      UI.messagebox latitude
      else
      UI.messagebox "Failure"
      end
      

      It doesn't return a latlon object, but a point3d object. And I need a latlon...

      Help greatly appreciated !

      DB

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

        The 3D point it returns is in the format 'long/lati/height'.
        The 'X' is the longitude in degrees [actually it's in 'inches'!]
        The 'Y' is the latitude in degrees [actually it's in 'inches'!]
        The 'Z' is the point's height in inches.
        To return the long/lati use
        latlong = model.point_to_latlong(point)

        (55, -1, 0) - this is for the 'ORIGIN' where I live...
        To set it as 'degrees' - for use in other methods you can use...
        long = latlong.x.to_f lati = latlong.y.to_f high = latlong.z.to_l [in current units]
        -1.0, 55.0 and 0.0
        You can then use
        ll = [lati, long]

        Note how perversely it takes 'lati/long' in the reversed order from the 'point' itself!

        my_ll = Geom::LatLong.new(ll)

        LatLong(55.00000N, 1.00000W)
        my_ll.latitude >>> 55.0
        my_ll.longitude >>> -1.0
        It's not the easiest or most logical method in the API!
        πŸ€“

        TIG

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Thanks a million TIG πŸ‘

          DB

          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