Pasting into the ruby console
-
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'
-
@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.
-
-
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....
-
Thanks for checking! I'll be looking into this more for sure. Maybe a new Mojave OS quirk. Have to work now.
Peter
-
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.
-
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...
-
Thanks I didn't see it saved as rtf. That makes sense.
Advertisement