Controlling clipboard from SketchUp (via Ruby or other method)

Every few SketchUp releases they break the console somehow, or the IO return from system commands.

Somewhere I posted a fix for the system (global backtick) methods.
Ah here it is … Getting unique ID of a user's machine - #5 by DanRathbun, post 5

1 Like

Here’s an example using Fiddle that comes out of the box with Ruby:

Biggest challenge was navigating the Win32 API and all their layers of compatibility overloads.

3 Likes

The link is down.

Oops, I’d created it as a private repo. I just made it public, please try again.

there is no need for the CLIPDIR on mac…

  def copy(text)
    `echo "#{text}" | pbcopy`
  end

  def paste()
    `pbpaste`
  end
  # in >>
  copy('copy can be less complex')
  # << out
  paste.inspect
  # returns =>
  "copy can be less complex\n"
  # so you need to be aware of the \n...
  # or use chomp and add your own formatting if needed...
   def paste()
    `pbpaste`.chomp
   end

john

2 Likes

I put the CLIPDIR and “clip.txt” on both platforms for 3rd party applications, just in case those needed to read from a file. The OP never said what the other applications were, what their scripting capabilities were, etc.

# so you need to be aware of the \n... or use chomp

Added .chomp to above example. (I had it on Windows already.)

Not sure why this was flagged - it’s as good an answer as any in this thread. A cut/paste workflow seems like the worst of all worlds solution - bottom of the barrel stuff. Surely a better solution exists, or at the least an automated one. Automation is exactly what computers are good for.

Perhaps if we had more information on the external software.

1 Like

Yes, I was surprised at the reaction to my contribution. But not offended.

I agree with you that knowing more about the problem posed its a necessary to giving a better answer.

Seasons greetings!