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

    Ruby console units

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    3 Posts 2 Posters 481 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
      th3lurker
      last edited by

      Hi!
      I'm sure this is a newbie question, probably asked many times before, but i searched for it on the forum and i couldn't find it.
      I'm very new to ruby (less than a week) and i have some experience with sketch-up(hobby, designing furniture for my new apartment).
      So here goes nothing. What unit does sketch-up use internally? For example, if i use the line = entities.add_line point1,point2 command, the coordinates for the points are considered inches, even with my template set to cm.
      It's not a big deal, but i plan to write an export to sketchup tool(more like an import to sketchup plugin) for the company's software(it uses the metric system). Do i have to use the numeric.cm & co commands or can i just set the unit to whatever i want?
      Thanks

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        Yup, SketchUp's internal units are inches.

        Check out the enhancements SketchUp has done to the numeric class to help convert easier between units.

        http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html

        There is also a parse_length command available that will help parse a string.

        Sketchup.parse_length("50m") though I think Adam just recently noted a bug with that method. I already forgot what it was though.

        So if the user enters "10" you can parse that and SU will turn it into a number in inches equal to 10 nodel units. If the model is in meters, it will return 393.700787401575 (inches). Then take that number and run it though Sketchup.format_length(393.700787401575) to format inches into model units - 10.0m

        Try this exercise to see how to take what the user enteres, turn it into inches for SketchUp to work with, then back into meters to display to the user again.
        len = Sketchup.parse_length("10") puts len len = Sketchup.format_length(len) puts len

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

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

          Thank you Chris.
          Well since it's in inches i'm going to have to use the .mm type of commands. I don't care/need to know what template the user uses, it's just operations would have been simpler.

          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