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

    [solved] Scale to length

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 224 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.
    • K Offline
      kdasilva
      last edited by kdasilva

      hello again, sorry for asking another question while my other is still not resolved~ but I had another question that has come up from another step of my tool.

      Can I use a length to create a scale transformation? Basically I am trying to scale a component to the length of the line? scale transformation requires a scale factor....

      I was thinking I could take then length of the line, ie 12, and then divide it by the length of the component, ie 3, to get a scaling factor of 4? However I got stumped on this part due to units...my component measured 6' 1/4" not sure how I put this value into a variable I can use to divide my line length...

      is their an easier way? and if not...could someone enlighten me on how to use the units? (I guess I could just switch the model to mm, but I would rather not as its not intuitive for community members at the urban design scale [my audience])

      thanks again!

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Sketchup uses Inches internally.

        Class Length is in inches. See:
        http://code.google.com/apis/sketchup/docs/ourdoc/length.html

        For conversion between defferent units use the methods of Numeric (which is the superclass of Float, which is the superclass of Length.) So both those subclasses inherit the conversion methods.
        http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html

        Just use a Float for fractions:
        6.25

        Use can get your number from complex fraction like so:
        var = 3 + (15.0/32.0)

        But the fractional display is only in the dialogs and the VCB (Measurements inputbox).. when you get the length of the line in Ruby, it will be a Float.

        I'm not here much anymore.

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

          As said...
          Irrespective of the Model Info > Units settings the length of the line and the length of the component-instance are always in 'inches' as remembered inside Sketchup [decimal-number], so diving one by the other gives a scaling factor as a decimal number [.to_f] that you can use in the scaling-transformation...

          TIG

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

            Off topic, but I like this one-liner:

            def inch2modelUnit(v)
            	return [v,v.to_feet,v.to_mm,v.to_cm,v.to_m][Sketchup.active_model.options["UnitsOptions"]["LengthUnit"]]
            end
            

            DB

            1 Reply Last reply Reply Quote 0
            • K Offline
              kdasilva
              last edited by

              Ah i see the to_f worked perfectly, for some reason I was trying to convert it into feet with decimal places last night, not sure why....my brain was not quite as sharp after about 15 hours of coding/writing last night~

              cheers
              Korbin

              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