pasting into the ruby console

General discussion related to SketchUp Pro and Make

pasting into the ruby console

Postby pbacot » Wed May 15, 2019 9:23 pm

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!
Code: Select all
> 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'
0
MacOSX Mojave ShetchUp Pro v19 Twilight Pro v2 M2 Kerkythea PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: pasting into the ruby console

Postby Gábor » Thu May 16, 2019 10:18 am

pbacot wrote: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.
0

Gábor 
 

Re: pasting into the ruby console

Postby pbacot » Thu May 16, 2019 10:30 am

Here is the TextEdit file.
0
MacOSX Mojave ShetchUp Pro v19 Twilight Pro v2 M2 Kerkythea PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: pasting into the ruby console

Postby Gábor » Thu May 16, 2019 2:35 pm

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....

fromForums.JPG

fromWordPad.JPG
0

Gábor 
 

Re: pasting into the ruby console

Postby pbacot » Thu May 16, 2019 4:51 pm

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

Peter
0
MacOSX Mojave ShetchUp Pro v19 Twilight Pro v2 M2 Kerkythea PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: pasting into the ruby console

Postby slbaumgartner » Mon May 20, 2019 2:30 pm

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.
0

slbaumgartner 
PluginStore Author
PluginStore Author
 

Re: pasting into the ruby console

Postby TIG » Mon May 20, 2019 2:46 pm

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...
1
TIG
User avatar
TIG 
Global Moderator
 

Re: pasting into the ruby console

Postby pbacot » Fri May 31, 2019 4:24 pm

Thanks I didn't see it saved as rtf. That makes sense.
0
MacOSX Mojave ShetchUp Pro v19 Twilight Pro v2 M2 Kerkythea PowerCADD
User avatar
pbacot 
Top SketchUcator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to SketchUp Pro & Make Discussions

Who is online

Users browsing this forum: No registered users and 9 guests

Visit our sponsors: