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

    Huh? Units? WTH?

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    4 Posts 3 Posters 143 Views 3 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.
    • I Offline
      installtechireland
      last edited by

      So, I have this code:

      def create_entities(data, container)

      a = data["a"].to_l
      w = data["w"].to_l
      h = data["h"].to_l
      
      pts = [[0,0,0], [a,0,0], [a,w,0], [0,w,0], [0,0,0]]
      base = container.add_face pts
      

      Obviously, that's not the whole thing. It makes a box eventually, based on the points defined above.

      Now, I want to alter the box to mae one side shorter than the other.

      The default Length "a" is 1000mm. When I replace point [a,0,0] with [a-20,0,0] I get a weird result. I expect a-20 to be 980mm, but I end up with a side that is 492mm, which implies Sketchup is taking off 20 inches, not mm. How do I tell it to read all units as mm? I am using the Engineering (mm) template if that makes any difference.

      Any help appreciated.

      Regards,

      Cathal

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

        If ' a' is in mm and you use a-20 you are taking of 20" !
        Use a-20.mm πŸ˜’
        Raw numbers are assumed to be in inches ALWAYS!

        TIG

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Make use of the Length class, and the extended method of String and Numberic to let SU handle the units. Remember that SU uses inches internally at all time. Units are presented to the user in the correct format using the assisting methods.

          Length class: http://code.google.com/apis/sketchup/docs/ourdoc/length.html
          Numeric class: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html
          String class: http://code.google.com/apis/sketchup/docs/ourdoc/string.html

          Keep track of whether your object is a Float or Length - as that matters when the number is outputted as string to the user.

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • I Offline
            installtechireland
            last edited by

            ...

            ah yes. I was using "a-20mm", not "a-20.mm", wondering why it didn't work...

            thanks πŸ˜„

            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