sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Mathematics related problem

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    23 貼文 4 Posters 2.5k 瀏覽 4 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • M 離線
      meeta
      最後由 編輯

      	prompts = ["Enter the bending moment" ]
      		bending = [0.mm]
      		results = inputbox prompts, bending, "Analyse Beam"
      		@M = bending
      		# Enter @M = 340000000 at this point for testing
      		@K = ((@M).to_f / (@b*(@d**2)*@fck))
      		
      		UI.messagebox (@K)
      
      

      when I do this in sketchup,
      I am getting @K = 1.9999

      I dont understand I put UI.messagebox for all values they are fine, when I run the same code in IRB its still fine. I have tried several other options changed the order here and there still stuck!

      I have another question, instead of using [0.mm] can I use anything else? It should actually be Nmm, how can I make that appear on sketchup message box?

      Meet A

      1 條回覆 最後回覆 回覆 引用 0
      • thomthomT 離線
        thomthom
        最後由 編輯

        @meeta said:

        I dont understand I put UI.messagebox for all values they are fine, when I run the same code in IRB its still fine. I have tried several other options changed the order here and there still stuck!

        What is the problem/error? What is expected?

        @meeta said:

        I have another question, instead of using [0.mm] can I use anything else? It should actually be Nmm, how can I make that appear on sketchup message box?

        bending = ["Nmm"] ?
        btw, 0.mm is the same as 0.

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

        1 條回覆 最後回覆 回覆 引用 0
        • M 離線
          meeta
          最後由 編輯

          sorry I missed this part out

          @b = 300
          @d = 600
          @fck = 40

          which should give me @K = 0.089 instead of 1.99

          Meet A

          1 條回覆 最後回覆 回覆 引用 0
          • thomthomT 離線
            thomthom
            最後由 編輯

            When I substitute your variables with the values you mentioned and run it in the Console I get:

            ` k = (340000000.0 / (300*(600**2)*40))

            0.0787037037037037`

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

            1 條回覆 最後回覆 回覆 引用 0
            • M 離線
              meeta
              最後由 編輯

              OMG i misquoted again... sorry about that
              yes it is supposed to come
              @K = 0.07870

              Meet A

              1 條回覆 最後回覆 回覆 引用 0
              • thomthomT 離線
                thomthom
                最後由 編輯

                Seems to be an issue with the inputbox:

                (I entered 340000000 into the inputbox)

                
                prompts = ["Enter the bending moment" ]
                ["Enter the bending moment"]
                
                bending = [0.mm]
                [0.0]
                
                results = inputbox prompts, bending, "Analyse Beam"
                [13385826.7716535]
                
                

                But if you instead do:

                
                prompts = ["Enter the bending moment" ]
                ["Enter the bending moment"]
                
                bending = ['Nmm']
                ["Nmm"]
                
                results = inputbox prompts, bending, "Analyse Beam"
                ["340000000"]
                
                

                So it seems that if the default value is a Number or Length - then Sketchup will return that type. In this case there was a problem as it converted 340000000 into inches.

                It seems to only occur when you pass a Length - not a Number.

                
                prompts = ["Enter the bending moment" ]
                ["Enter the bending moment"]
                
                bending = [0]
                [0]
                
                results = inputbox prompts, bending, "Analyse Beam"
                [340000000]
                
                

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

                1 條回覆 最後回覆 回覆 引用 0
                • TIGT 離線
                  TIG Moderator
                  最後由 編輯

                  An input box always takes the 'type' of its input as that set by the initial default value: so start with:
                  1 if you expect an integer input e.g. 12
                  1.0 if you expect a float input e.g. 12.345
                  1.mm if you expect a length input e.g. 12.3, 1mm, 12.3mm, 12"
                  "" if you expect text-string input, e.g '1 gallon' [which you'd then parse for info]

                  TIG

                  1 條回覆 最後回覆 回覆 引用 0
                  • thomthomT 離線
                    thomthom
                    最後由 編輯

                    @tig said:

                    An input box always takes the 'type' of its input as that set by the initial default value:

                    This is something that should be on the manual. I'll add it to the list.

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

                    1 條回覆 最後回覆 回覆 引用 0
                    • M 離線
                      meeta
                      最後由 編輯

                      yes i can see what you mean.. this is confusing for me.. I will do some experiments and figure it out! thank you fellows 😄

                      Meet A

                      1 條回覆 最後回覆 回覆 引用 0
                      • thomthomT 離線
                        thomthom
                        最後由 編輯

                        All you need to do is not pass on the default value as a Length class. Use Float, Integer or String.

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

                        1 條回覆 最後回覆 回覆 引用 0
                        • G 離線
                          Gruff
                          最後由 編輯

                          Perhaps I am just a raw beginner myself but it appears that in his original snippet meeta is setting @M = bending.

                          Shouldn't that be @M = result?

                          Inputbox does not alter the input default value that I can see.
                          therefore bending will still be 0.0 after the input.

                          Resistance is .... Character Forming. Grin

                          1 條回覆 最後回覆 回覆 引用 0
                          • M 離線
                            meeta
                            最後由 編輯

                            @gruff said:

                            Perhaps I am just a raw beginner myself but it appears that in his original snippet meeta is setting @M = bending.
                            Shouldn't that be @M = result?

                            yes your absolutely true.. i corrected that in my code and yet its showing the same results.. and besides if it were to be 0 then @M / 'anything ' = NaN? there is some problem there.. but I got a newer problem after sorting that out.. this is more interesting i reckon.. please have a look at this

                            @b = 300
                                  @h = 280
                                  weight =((25.0*@b*@h) / 10**6)
                                  prompts = ["Variable Load(kN/m) ", "Permanent Load(kN/m) ", "Max Moment known(Nmm)"]
                                  loads = [0.0, 0.0, 0.0] #At this point enter 21, 50.1 and 0
                                  results = inputbox prompts, loads, "Loads apart from Self-weight/ Or if moment is known, Please enter"
                                  variable_load, permanent_load, moment = results
                            		
                            		if (moment != 0) 
                            			@M = moment
                            		else
                            			uls = (1.35*variable_load + 1.5*permanent_load + 1.5*weight)*@length
                            			UI.messagebox(@M)
                            			UI.messagebox(weight)
                            			UI.messagebox(results)
                            			@M = 0.11*uls*@length 
                            			@shear = 0.60 * uls 
                            			UI.messagebox(uls)
                            			UI.messagebox(@M)
                            		end
                            	
                            

                            I don't know why, the weight that it should be showing is 2.1, but its showing 0.0032 something at the very beginning of the code.. its really taking a toll on me now! I know that many UI boxes is absolutely silly but that's my way of debugging because I know no other way! pls recommend any other method for debugging!

                            Meet A

                            1 條回覆 最後回覆 回覆 引用 0
                            • thomthomT 離線
                              thomthom
                              最後由 編輯

                              @meeta said:

                              I know that many UI boxes is absolutely silly but that's my way of debugging because I know no other way! pls recommend any other method for debugging!

                              Output the values to the Ruby Console, use the puts method. puts "Hello World"

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

                              1 條回覆 最後回覆 回覆 引用 0
                              • M 離線
                                meeta
                                最後由 編輯

                                @thomthom said:

                                @meeta said:

                                I know that many UI boxes is absolutely silly but that's my way of debugging because I know no other way! pls recommend any other method for debugging!

                                Output the values to the Ruby Console, use the puts method. puts "Hello World"

                                yes i tried doing that,, but strangely the answer in ruby is always right but not in sketchup! so i figured something must be wrong in the code or in sketchup! hopefully its my code because that'll be easier to fix

                                Meet A

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  @meeta said:

                                  yes i tried doing that,, but strangely the answer in ruby is always right but not in sketchup! so i figured something must be wrong in the code or in sketchup! hopefully its my code because that'll be easier to fix

                                  ??
                                  You are aware of the Ruby Console window in Sketchup, right? That's the one I'm referring to. That will let you see the values you get from the script running in SU's Ruby.

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

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • M 離線
                                    meeta
                                    最後由 編輯

                                    @thomthom said:

                                    You are aware of the Ruby Console window in Sketchup, right? That's the one I'm referring to. That will let you see the values you get from the script running in SU's Ruby.

                                    oh you mean that ruby console,, i thought you were talking of the interactive ruby console.. sorry about them.. let me try it out now!

                                    Meet A

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • thomthomT 離線
                                      thomthom
                                      最後由 編輯

                                      There are people that have worked out how to hook up debuggers to SU's ruby. But I've so far managed by using the Sketchup Ruby Console to output data throughout the script when I need to debug errors and abnormalities. It's the Sketchup Ruby Console that most people here on this forum will be referring to when they mention the Console.

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

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • M 離線
                                        meeta
                                        最後由 編輯

                                        ohh really? thanks i am newb with sketchup programming have been using sketchup for a few years though.. anyways now i wont look like a fool if anyone says console and i think of the irb! thanks

                                        Meet A

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • thomthomT 離線
                                          thomthom
                                          最後由 編輯

                                          For most people here, the Sketchup Ruby Console is the debugging tool. Some are also using Jim's custom console which has some extended features.

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

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • thomthomT 離線
                                            thomthom
                                            最後由 編輯

                                            FYI, I'd never used Ruby before I started making plugins for SU. And I only recently installed a normal Ruby installation on my computer - never touched a full Ruby installation before.

                                            So there's no wonder we're getting confused here. 😄

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

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement