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

    Pasting into the ruby console

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    8 Posts 4 Posters 1.4k 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.
    • pbacotP Offline
      pbacot
      last edited by

      I can paste code that is from this forum into the ruby console and it works. But if I paste into TextEdit doc and then copy that into the ruby console it doesn't. Shouldn't that work? I get this error. Trying to save it for later use. Thanks!

      > mod = Sketchup.active_model
      ent = mod.entities
      sel = mod.selection
      SKETCHUP_CONSOLE.clear
      edgs = sel.grep(Sketchup;;Edge)
      if edgs[0]
        vers = edgs.map{|e|e.vertices}.flatten.uniq;
        vecs = []; vrts = []; axis = [0,0,-1]
        for v in vers
          p=v.position;
          h=mod.raytest([p,axis]);
          if h
            vrts << v;
            vecs << p.vector_to(h[0])
          end
        end
        ent.transform_by_vectors(vrts,vecs)
      else
        puts "select edge(s)"
      end
      Error; #<SyntaxError; <main>;17; syntax error, unexpected keyword_else, expecting end-of-input>
      SketchUp;1;in `eval'
      
      

      MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gábor
        last edited by

        @pbacot said:

        I can paste code that is from this forum into the ruby console and it works. But if I paste into TextEdit doc and then copy that into the ruby console it doesn't.

        Could you please attach the "TextEdit doc" as well? For those who doesn't have a MAC therefore can't replicate the phenomena.

        1 Reply Last reply Reply Quote 0
        • pbacotP Offline
          pbacot
          last edited by

          Here is the TextEdit file.


          sdmitchmoveverticestosurface.rtf.zip

          MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

          1 Reply Last reply Reply Quote 0
          • G Offline
            Gábor
            last edited by

            Thank you for the TextEdit file. I could reproduce it on PC by opening your .rtf file in Wordpad and copy/pasting the code into the Ruby console. It is weird.

            After it I've copy/pasted the code into a Notepad++ document both from the forums and from wordpad, the two codes visually looked exactly the same. Though if I copy the code to SketchUp from that notepad++ document what was copied from the forums it runs without any problems but if I copy it from the document copied from the wordpad it shows the same error you referred to. Weird.

            After it I saved both notepad++ files and surprise! They had different sizes though they visually looked exactly the same.

            I opened these saved files in hexeditor and I saw that the one copied from TextEdit represents the space characters at the beginning of the line with 3 characters (C2 A0 20) while the one copied from the forums represents them only with character hex 20. This suggests some character encoding issue what might be the cause of the problem. Does TextEdit has an option to set the character encoding? Can you set it to ASCII and try it again?

            I'm not sure if this is the reason but this is the only difference what I could identify between the 2 copies....

            The file copied from the forums
            The file copied from WordPad

            1 Reply Last reply Reply Quote 0
            • pbacotP Offline
              pbacot
              last edited by

              Thanks for checking! I'll be looking into this more for sure. Maybe a new Mojave OS quirk. Have to work now.

              Peter

              MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

              1 Reply Last reply Reply Quote 0
              • S Offline
                slbaumgartner
                last edited by

                C2 A0 is the unicode for non-breaking space (html nbsp), so this looks like an issue with how this character is being handled by the various apps.

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

                  Why are you using an RTF file at all ?
                  As its name implies, there might be some "Rich-Text-Formatting" - changing the actual text.
                  It's only doing what you'd expect.
                  Potentially it won't be plain-text any more...
                  You wouldn't expect a DOC file to be plain-text, would you ?

                  But a simple TXT file has no formatting - it's unadorned plain-text.

                  On a MAC something like TextWrangler is the equivalent of PC's Notepad++ - keeping its text as UTF-8 encoding in plain-text, with correct formatting etc...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • pbacotP Offline
                    pbacot
                    last edited by

                    Thanks I didn't see it saved as rtf. That makes sense.

                    MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

                    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