- 积分
- 1905
- 明经币
- 个
- 注册时间
- 2022-4-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 枫叶棋语 于 2022-5-10 16:59 编辑
# -*- coding: utf-8 -*
import re
import clr
from pycad.runtime import *
from pycad.system import *
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Clipboard
fd_str = ""
@command()
def fd(doc):
with dbtrans(doc) as tr:
global fd_str
res =edx.getstr("请输入查找文字 ")
if not res.ok: return
str0=res.value
if str0 == "":
str0=fd_str
pa= "^\s*|\s*$"
str0=re.sub(pa, "", str0, count=0, flags=0)
print(str0)
fd_str = str0
ss_list=[]
ss = edx.ssget_x((0, '*text'))
if ss.ok():
for ssi in ss:
txt=tr.getobject(ssi.ObjectId)
with upopen(txt):
if isinstance(txt, acdb.DBText):
str1 = txt.TextString
elif isinstance(txt, acdb.MText):
str1 = txt.Text
if not re.match(str0 , str1, re.I) is None:
ss_list.append(ssi.ObjectId)
edx.sssetfirst(tuple(ss_list))
@command()
def ff(doc):
with dbtrans(doc) as tr:
str0 = Clipboard.GetText()
if not str0:
print("剪贴板为空")
else:
Clipboard.Clear()
ss = edx.ssget_x((0, '*text'))
pa= "^\s*|\s*$"
str0=re.sub(pa, "", str0, count=0, flags=0)
print(str0)
Clipboard.SetText(str0)
ss_list=[]
if ss.ok():
for ssi in ss:
txt=tr.getobject(ssi.ObjectId)
with upopen(txt):
if isinstance(txt, acdb.DBText):
str1 = txt.TextString
elif isinstance(txt, acdb.MText):
str1 = txt.Text
if not re.match(str0 , str1,re.IGNORECASE) is None:
ss_list.append(ssi.ObjectId)
edx.sssetfirst(tuple(ss_list))
|
|