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

    Sketchup.format_area bug?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 284 Views 4 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.
    • thomthomT Offline
      thomthom
      last edited by

      With model units set to inches:
      ` > Sketchup.format_area(100)
      100 Inches ²

      Sketchup.format_area(2540.mm)
      100 Inches ²`

      With model units set to mm:
      ` > Sketchup.format_area(100)
      64516 Millimeters ²

      Sketchup.format_area(2540.mm)
      64516 Millimeters ²`

      Surely this is a bug? Should they not yield that same results? Or am I missing something? I can't make sense out of the results I get with the model units set to mm.

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

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

        Sketchup.format_area(number)
        You are passing a number as 100 [which SUp assumes is inches] but it's a length as 2540.mm, however, Sketchup.format_area(2540.mm * 1.mm) will return the expected result as 2540 sqmm, as length x length = number, in inches [3.93700787401575] ?

        TIG

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

          I'm not quite following what you are saying. The input of Sketchup.format_area is not constant of inches?

          Sketchup.format_area(100) yields different result depending on the model settings. If the expected input is inches, then it the result should be the same regardless of model units.

          If it assumes the number is in the model units, then with mm Sketchup.format_area(100) should return "100 Millimeters ²" - but it does not.

          I don't understand the value it returns.

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

          1 Reply Last reply Reply Quote 0
          • C Offline
            cjthompson
            last edited by

            I'm not sure if you noticed this, but 2540 squared equals 6451600. That might explain the result.
            I don't know why it omitted the last two zeros, though.

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

              That's the thing - the numbers doesn't seem to add up at all.

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

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                You're making it hard for some reason.

                format_area expects inches (apparently.)

                2540.mm == 100.0 inches. ( .mm converts to inches.)

                and 100 in² == 64516 mm²

                Hi

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

                  Ok - my bad. I was being silly and didn't consider I was dealing with squares when I typed 100.mm.

                  Sketchup.format_area(100.mm**2) 10000 Millimeters ²

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

                  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