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

    Fractions and units display

    Scheduled Pinned Locked Moved Plugins
    4 Posts 3 Posters 237 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.
    • K Offline
      ktkoh
      last edited by

      I have the K2WS_Tools out for beta testing and a problem has shown up with fractions with unit display checked. I pass the input to Arithmetic parsing so fractions and equations are accepted. However with an input of 1/4" the units display the input is not processed into an SU length and the program bombs. I am thinking about parsing the input to remove the trailing " as I could in basic but so far I have not found enough the help file to tell me how to do this. I could use your help.

      Or if there is a better way of handling this problem I am also open to suggestions.

      Thanks
      Keith

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

        Should you just split the string '1/4"' at the / then take then add a " to the first part then make both into lengths then do the division ?

        input='1/4"'

        1/4"
        fract=input.split("/")
        ["1", "4""]
        fact[0]=fract[0]+'"'
        "1""
        fract
        ["1"", "4""]
        ans=fract[0].to_l / fract[1].to_l
        0.25

        OR perhaps even easier you could strip off the trailing " thus

        input.gsub!(/"$/,'')

        1/4
        fract=input.split("/")
        ["1", "4"]
        ans=fract[0].to_f / fract[1].to_f
        0.25

        🤓

        TIG

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

          Is there a model variable that would tell me what the units setting is? It might help the problem if I could change the units while the program runs and then change it back before the program exits. I did find a way to strip the inch unit sign

           @hasInch = @fpt.to_s =~ /\"/ ; if @hasInch then @fpt=@fpt[0,@hasInch] end
          

          however this was not a complete solution as calculations still stopped the program.

          @xcl[0]=x1+(@hpt-((@fpt)/2))
          

          These equations don't work when the @fpt variable is a fraction. And I also found out that other areas of my program where I am working on geom a float number does not seem to work. There are obviously many things I don't understand about length variables. Any thoughts or suggestions will be appreciated.

          Keith

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

            Not sure what the problem is? What are you trying to do?

            Hi

            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