• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby console units

Scheduled Pinned Locked Moved Newbie Forum
sketchup
3 Posts 2 Posters 481 Views
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 18 Oct 2011, 06:55

    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
    • C Offline
      Chris Fullmer
      last edited by 18 Oct 2011, 07:50

      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 18 Oct 2011, 10:50

        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
        1 / 1
        • First post
          2/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement