sketchucation logo sketchucation
    • Login
    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!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    Does "C" equal "C" ?

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 8 Posters 1.2k Views 8 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.
    • M
      MartinRinehart
      last edited by Gábor

      Edit: Of course "C" equals "C", (if you don't compound one mistake with another). 😳 Got a better way to handle the WebDialog.set_file() issue, which I'll add to that subject's discussion. Otherwise, this was just stupidity that I'll blame on too much snow shoveling.

      Back to the WebDialog.set_file() problem. I stumbled across the Ruby File.expand_path() method that looks like a better replacement for the little fixup() function I wrote. If you File.expand_path(__FILE__) you get the full path back to the root, on a Mac, or the drive, on a PC. Perfect!

      Except that "C:..." does not equal "C:..." in the following:

      # /models/airshow/t.rb
      
      =begin
      On a PC, WebDialog.set_file() requires a drive specification.
      
      So you get the working directory; dir = Dir;;pwd()
      
      The working directory will start with;
      '/' on a Mac
      'C;' (or 'D;' or ...) on a PC
      
      47 == '/'
      58 == ';' 
      
      Prefix the given pathname with 'C;' (or 'D;' or ...) unless
          a) you are on a Mac
          b) the given pathname already includes a drive specification
      =end
      def fixup( pathname )
          dir = Dir;;pwd()
          pathname = dir[0..1] + pathname unless 
              ( dir[0] == 47 ) || ( pathname[1] == 58 )
          return pathname
      end
      
      tfile = 'movie_titles.html'
      
      foo = File.expand_path( File.dirname(__FILE__) )
      foo = File.join( foo, tfile )
      puts foo = 'foo; "' + foo + '"'
      
      bar = fixup( File.dirname(__FILE__) )
      bar = File.join( bar, tfile ) 
      puts bar = 'bar; "' + bar + '"'
      
      puts 'same? ' + (foo==bar).to_s
      
      
      

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

        try using p str or puts str.inspect instead of puts str to see the exact string including the escape chars.

        Hi

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

          what is the intent of the code?

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

          1 Reply Last reply
          Reply Quote 0
          • T
            todd burch
            last edited by

            puts foo = 'foo: "' + foo + '"'
            puts bar = 'bar: "' + bar + '"'

            Of course they are not the same.

            1 Reply Last reply
            Reply Quote 0
            • M
              MartinRinehart
              last edited by

              @jim said:

              try using p str or puts str.inspect instead of puts str to see the exact string including the escape chars.

              Good idea, tho in this case it wasn't an escape chars issue.
              @thomthom said:

              what is the intent of the code?

              To replace a call to my routine with a better use of Ruby:

              
              # this code works, PC and Mac, any way that __FILE__ was loaded
              pathname = File.expand_path( File.dirname(__FILE__) )
              pathname = File.join( pathname, 'myFile.HTML' )
              wd.set_file( pathname )
              
              

              @unknownuser said:

              puts foo = 'foo: "' + foo + '"'
              puts bar = 'bar: "' + bar + '"'

              Of course they are not the same.

              Snow-blind coder error. 😳

              Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

              1 Reply Last reply
              Reply Quote 0
              • chrisglasierC
                chrisglasier
                last edited by

                Back to Uncle Holly stuff ... sigh

                With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

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

                  Everyone's done it. Yesterday I wrote this as an example:

                  def = Sketchup.active_model.selection[0].definition

                  Hi

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

                    @jim said:

                    Everyone's done it. Yesterday I wrote this as an example:

                    def = Sketchup.active_model.selection[0].definition

                    ...and I can't see what's wrong... ...time to go home...

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

                    1 Reply Last reply
                    Reply Quote 0
                    • Chris FullmerC
                      Chris Fullmer
                      last edited by

                      I'm glad that I've nevre mis-typed or mis-comprehended a single line of code, so I don't even begin to comprehend what you guys are talking about 🤣

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

                      1 Reply Last reply
                      Reply Quote 0
                      • T
                        todd burch
                        last edited by

                        @thomthom said:

                        @jim said:

                        Everyone's done it. Yesterday I wrote this as an example:

                        def = Sketchup.active_model.selection[0].definition

                        ...and I can't see what's wrong... ...time to go home...

                        def is a reserved word.

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

                          duh! I would have seen that with syntax highlighting... 😳

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

                          1 Reply Last reply
                          Reply Quote 0
                          • J
                            jessejames
                            last edited by

                            @unknownuser said:

                            @jim said:

                            Everyone's done it. Yesterday I wrote this as an example:
                            def = Sketchup.active_model.selection[0].definition

                            def is a reserved word.

                            WOW, good catch Todd, will you provided your eagle eye services to debug some of my code? 🤣

                            PS: i hope your rates are "reasonable" 😕

                            Always sleep with a loaded gun under your pillow!

                            1 Reply Last reply
                            Reply Quote 0
                            • J
                              jessejames
                              last edited by

                              @ Todd 😳 it seems that you are actually replying to ThomThom and not Jim and in that context your comment makes sense. The way you quoted it it looked like you where replying to Jim directly so looks like i am the boob here!

                              <<<<<<<<<<<<<|;-)

                              Always sleep with a loaded gun under your pillow!

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

                                @martinrinehart said:

                                ... I stumbled acrossthe Ruby File.expand_path() method that looks like a better replacement for the little fixup() function I wrote. If you File.expand_path(__FILE__) you get the full path back to the root, on a Mac, or the drive, on a PC. Perfect!

                                If you look back at the original thread, and reread more carefully, you'll see ThomThom told you to use File.expand_path() two weeks before you "stumbled across" it!

                                I've been wondering why you didn't take his advice... (and do you have a copy of the 'Pick-Axe' Ruby book in chm format?)

                                I'm not here much anymore.

                                1 Reply Last reply
                                Reply Quote 0

                                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                With your input, this post could be even better 💗

                                Register Login
                                • 1 / 1
                                • First post
                                  Last post
                                Buy SketchPlus
                                Buy SUbD
                                Buy WrapR
                                Buy eBook
                                Buy Modelur
                                Buy Vertex Tools
                                Buy SketchCuisine
                                Buy FormFonts

                                Advertisement