Python ClipboardText not working on mac?


#1

very puzzled why this doesn’t work? ty

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

#2

@kleerkoat,

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

import rhinoscriptsyntax as rs

c.


#3

@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?


#4

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


#5

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


#6

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.


(Steve Baer) #7

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


(Steve Baer) #8

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"

#9

thank you.

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


(Steve Baer) #10

Is the script that I posted not working for you?


#11

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


(Steve Baer) #12

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

#13

awesome! thank you!