pycad 横向,竖向复制文本,直接粘贴到excel
本帖最后由 枫叶棋语 于 2022-4-12 16:22 编辑# -*- coding: utf-8 -*
from pycad.system import *
from pycad.runtime import *
import clr, System
clr.ImportExtensions(System.Linq)
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Clipboard
@command()
def wq(doc):
#竖向复制文字
with dbtrans(doc) as tr:
str=""
i= 0
ss=edx.ssget(mode=':A',filters=(0,'*text'))
if (not ss.ok)and(len(ss.value)):return
texts=(
ss.Cast[acdb.ObjectId]()
.Select(lambda i: tr.getobject(i))
.OrderBy(lambda t: t.Position.X))
strlen=len(list(texts))
for text intexts:
i=1+i
if i !=strlen :
str=str+text.TextString+"\n"
else:str=str+text.TextString
Clipboard.Clear()
Clipboard.SetText(str)
@command()
def we(doc):
#横向复制文字
with dbtrans(doc) as tr:
str=""
i= 0
ss=edx.ssget(mode=':A',filters=(0,'*text'))
if (not ss.ok)and(len(ss.value)):return
texts=(
ss.Cast[acdb.ObjectId]()
.Select(lambda i: tr.getobject(i))
.OrderBy(lambda t: t.Position.Y))
list1=list(texts)
list1.reverse()
strlen=len(list1)
for text inlist1:
i=1+i
if i !=strlen :
str=str+text.TextString+"\n"
else:str=str+text.TextString
Clipboard.Clear()
Clipboard.SetText(str)
大神你这个是啥语言呀,如何用 664571221 发表于 2022-4-13 08:32
大神你这个是啥语言呀,如何用
我刚学习,用的pycad,python
页:
[1]