Python ClipboardText not working on mac?

very puzzled why this doesn’t work? ty

id = rs.GetObject("Pick any object")
if id:
    clip = rs.ClipboardText(id)
    print "Copied Identifier: ", id

@kleerkoat,

seems to work over here if i add this line on top of it:

import rhinoscriptsyntax as rs

c.

@clement it is copying the id to your clipboard? it works here, it’s just not copying anything to the clipboard. did you try on mac or win? would that matter?

It might. The method might not be hooked up yet on Mac, perhaps due to differences on how the clipboard is handled. It does work here under Windows. Have to check with someone on the Mac side.

–Mitch

ok, yeah, i just cranked up vmware and it does work under windows. hmmm.

Yes. It works but i am on Windoze too :wink: Internally, it seems to use:

System.Windows.Forms.Clipboard.SetText

Maybe try the suggestion in the 3rd post here ?

c.

This sounds like there is a bug in our implementation of System.Windows.Forms on OSX that needs to be tuned up.
https://mcneel.myjetbrains.com/youtrack/issue/MR-2982

For now, the following should work on Mac

import clr
clr.AddReference("Eto")
import Eto.Forms

cb = Eto.Forms.Clipboard()
cb.Text = "Hello From Rhino"

thank you.

where would i find more documentation on this way? not sure how to get it work.

Is the script that I posted not working for you?

yeah, it works. just wondering how to use it in my code.

Here ya go

import rhinoscriptsyntax as rs

# temp hack to get clipboard working on OSX
import clr
clr.AddReference("Eto")
import Eto.Forms
def ClipboardTemp(text=None):
    cb = Eto.Forms.Clipboard()
    rc = cb.Text
    if text: cb.Text = str(text)
    return rc
rs.ClipboardText = ClipboardTemp

# back to our regularly scheduled script...
id = rs.GetObject("Pick any object")
if id:
    clip = rs.ClipboardText(id)
    print "Copied Identifier: ", id
1 Like

awesome! thank you!