def clipboard(doc, args): from System.Windows.Forms import Clipboard count = len(args) if count == 0: return Clipboard.GetText() elif count == 1: Clipboard.SetText(args[0])
def copytoclipboard(args): """ Put data on Windows clipboard in csv format. """ csvx = "" if len(args) == 0: pass # clear clipboard # print 'clearing clipboard' elif len(args) == 1: csvx = args[0] else: csvx = "" csvx = ','.join(args) # print "-------------------", csvx dobj = DataObject() # hack from MSDN PostID 238181 # this is a bit bizarre, # but it works for getting csv data into Excel txt = Text.Encoding.Default.GetBytes(csvx) memstr = MemoryStream(txt) dobj.SetData('CSV', memstr) dobj.SetData(CSV, memstr) Clipboard.SetDataObject(dobj)
def CopyToClipboard(self): def __getData(item): if item.Tag: if item.Tag.startswith("silfw:"): return item.Text else: return Environment.NewLine.join( (item.Text, item.ToolTipText)) else: return item.Text data = [__getData(i) for i in self.Items] if data: Clipboard.SetText(Environment.NewLine.join(data)) else: Clipboard.Clear()
def cp2Clipboard(csvdata): # print( csvdata ) # dobj = DataObject() # txt = Text.Encoding.Default.GetBytes(csvdata) # memstr = MemoryStream(txt) # # dobj.SetData('CSV', memstr) # dobj.SetData(CSV, True ,txt) # Clipboard.SetDataObject(dobj) try: Clipboard.SetText(csvdata) except: pass print(csvdata)
def TypeA(): match = [] for i, j in x: try: if i == j: match.append((i, j)) except: pass if not match: AddWarningMessage('No match, Please check condition!') return None else: AddWarningMessage('{} matches!'.format(len(match))) [AddWarningMessage(str(i)) for i in match] result = ';'.join(['dB(S({},{}))'.format(i, j) for i, j in match]) Clipboard.SetText(result)
def GetInsertionLoss(): match = [] for i, j in x: try: if i[-8:] == j[-8:] and i.startswith('BGA') and j.startswith( 'FCHIP'): match.append((i, j)) except: pass if not match: AddWarningMessage('No match, Please check condition!') return None else: AddWarningMessage('{} matches!'.format(len(match))) [AddWarningMessage(str(i)) for i in match] result = ';'.join(['dB(S({},{}))'.format(i, j) for i, j in match]) Clipboard.SetText(result)
def TypeB(): match = [] for i, j in x: try: mi = re.search('_(\d+)_.*S(\d+)', i) mj = re.search('_(\d+)_.*S(\d+)', j) if mi.group(1) != mj.group(1) and mi.group(2) == mj.group(2): match.append((i, j)) except: pass if not match: AddWarningMessage('No match, Please check condition!') return None else: AddWarningMessage('{} matches!'.format(len(match))) [AddWarningMessage(str(i)) for i in match] result = ';'.join(['dB(S({},{}))'.format(i, j) for i, j in match]) Clipboard.SetText(result)
def main(): # 解析战斗数据 battleDataRaw = Clipboard.GetText() try: global battleData battleData = json.loads(battleDataRaw) except ValueError: print("无法解析战斗数据,请确认数据已经复制到剪贴板") return # 检查最后一个配置 if Utility.Groups.Count == 0 or Utility.Groups[Utility.Groups.Count - 1].Count != 0: print("请先手动创建一个空配置并放置到配置列表的末尾" ) # Utility.Groups.Add方法受保护(否则付费功能就没意义了),外部无法调用。 return group = Utility.Groups[Utility.Groups.Count - 1] # 构造备忘执行单元 memo = createMemoWorkflow(battleData) Dispatcher.Invoke(lambda: group.Add(memo)) # 直接在独立线程添加执行单元会报错 # 构造编成执行单元 mainFleet = createBasicOrganizeFleetWorkflow(battleData["fleet"]["main"], 1) Dispatcher.Invoke(lambda: group.Add(mainFleet)) if battleData["fleet"]["escort"] is not None: # TODO:尚未测试 # 添加伴随舰队 escortFleet = createBasicOrganizeFleetWorkflow( battleData["fleet"]["escort"], 2) Dispatcher.Invoke(lambda: group.Add(escortFleet)) # 添加组成联合舰队 combine = createBasicCombinedFleetWorkflow(battleData["fleet"]["type"]) Dispatcher.Invoke(lambda: group.Add(combine)) # 构造改装执行单元 mainRefit = createBasicRefitEquipmentWorkflow(battleData["fleet"]["main"], 1) Dispatcher.Invoke(lambda: group.Add(mainRefit)) if battleData["fleet"]["escort"] is not None: # TODO:尚未测试 escortRefit = createBasicRefitEquipmentWorkflow( battleData["fleet"]["escort"], 2) Dispatcher.Invoke(lambda: group.Add(escortRefit))
def TypeD(): match = [] for i, j in x: try: mi = re.search('_(\d+)_.*S(\d+)', i) mj = re.search('_(\d+)_.*S(\d+)', j) if mi.group(1) == mj.group(1) and (mi.group(2), mj.group(2)) in [ ('3', '4'), ('7', '8'), ('9', '10'), ('14', '15') ]: match.append((i, j)) except: pass if not match: AddWarningMessage('No match, Please check condition!') return None else: AddWarningMessage('{} matches!'.format(len(match))) [AddWarningMessage(str(i)) for i in match] result = ';'.join(['mag(Z({},{}))'.format(i, j) for i, j in match]) Clipboard.SetText(result)
def GetClipboardText(): text = "" if cb.ContainsText(): text = cb.GetText() return text
def SetClipboardText(text): cb.SetText(text)
def copy_envvar_id(self, sender, args): """Callback method for copying selected env var name to clipboard """ Clipboard.SetText(self.envvars_lb.SelectedItem.Id)
import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import Clipboard try: Clipboard.SetText(IN[0]) OUT = IN[0] except: OUT = 'Data could not be copied to clipboard'
def copy_envvar_id(self, sender, args): Clipboard.SetText(self.envvars_lb.SelectedItem.Id)
def copy_envvar_value(self, sender, args): Clipboard.SetText(self.envvars_lb.SelectedItem.Value)
# clear session word_application = Word.ApplicationClass() word_application.Quit() word_application = None # word_application = Word.ApplicationClass() word_application.visible = True doc_word = word_application.Documents.Open(source_filenamePath) fecSymb = FilteredElementCollector(doc).OfCategory( BuiltInCategory.OST_Doors).WhereElementIsElementType().ToElements() imgSize = System.Drawing.Size(100, 100) for symb in fecSymb: # add Image bitm = symb.GetPreviewImage(imgSize) Clipboard.SetDataObject(bitm) doc_end1 = doc_word.Content.End - 1 doc_end2 = doc_word.Content.End rng = doc_word.Range(doc_end1, doc_end2) rng.Paste() # add NAme and Description doc_end1 = doc_word.Content.End - 1 doc_end2 = doc_word.Content.End rng = doc_word.Range(doc_end1, doc_end2) famName = symb.Family.Name symbName = Element.Name.GetValue(symb) description = symb.get_Parameter( BuiltInParameter.ALL_MODEL_DESCRIPTION).AsString() rng.Text += "Family : {}\nType : {}\nDescription : {}\n".format( famName, symbName, description)
def copy_record_originalrecord(self, sender, args): Clipboard.SetText(unicode(self.current_record.original_record))
def copy_record_script(self, sender, args): Clipboard.SetText(self.current_record.scriptpath)
def copy_record_revitbuild(self, sender, args): Clipboard.SetText(self.current_record.revitbuild)
catJoin = elif0, pathlink, elif1, c, elif2, filterIn, elif3 temp = ''.join(catJoin) listLines.append(temp) lines = '\r\n'.join(listLines) # the final line starts with else # rows not in cats are given the filterOut value strElse = ''.join(('else "', filterOut, '")')) # the code is brought together with new lines between each line code = '\r\n'.join((table, lines, strElse)) # ------------------------ # send to clipboard # ------------------------ # annotated with kudos to bakery 'by send to clipboard from revit' (sic) # https://github.com/LukeyJohnson/BakeryForDynamo/blob/97e5622db7ba14cd42caac9b8bd4fdba6b66871e/nodes/bv%20Send%20to%20Clipboard%20from%20Revit.dyf#L5-L12 # try to copy the code, provide a message if it fails try: Clipboard.SetText(code) copyMsg = code except: copyMsg = 'Data could not be copied to clipboard' # ------------------------ # output # ------------------------ OUT = copyMsg
def copy_record_pyrevit(self, sender, args): Clipboard.SetText(self.current_record.pyrevit)
import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import Clipboard try: OUT = Clipboard.GetText() except: OUT = 'Clipboard contents could not be retrieved'
def copy_record_commandresults(self, sender, args): Clipboard.SetText(unicode(self.current_record.commandresults))
def add_to_clipboard(self, v, arr): Clipboard.SetText(self.label.Text) message("Лог скопирован в буфер обмена.")
def copy_record_logfilename(self, sender, args): Clipboard.SetText(unicode(self.current_record.logfilename))
def callback(value): from System.Windows.Forms import Clipboard Clipboard.Clear() Clipboard.SetText(value)