首页 > 行业资讯 > 用Python编写CAD插件(增加文本前缀源码)

用Python编写CAD插件(增加文本前缀源码)

时间:2023-09-11 来源: 浏览:

用Python编写CAD插件(增加文本前缀源码)

逆流而上的鱼 CAD工具插件
CAD工具插件

CAD5299

CAD小懒人工具有750个功能,包含经营权工具,另外还有宅基地、不动产工具

收录于合集

用Python编写CAD插件

说明:用Python编写CAD插件,批量给文字增加前缀“A-”

<iframe allowfullscreen="" class="video_iframe rich_pages" data-cover="http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2Fx1hdibLLJ83guibpIYt76WLaW8qzBqEzkrZiaHoUtp4MKpBIibF5icvjfaLibTy0Sboy675JfBGia9odf1icxzOCmoEM4A%2F0%3Fwx_fmt%3Djpeg" data-mpvid="wxv_3099316959814369283" data-ratio="0.7375886524822695" src="http://www.cnmhg.com/e/admin126459646/showimg.php?url=https://mp.weixin.qq.com/mp/readtemplate?t=pages/video_player_tmpl&action=mpvideo&auto=0&vid=wxv_3099316959814369283" data-vidtype="2" data-w="624" frameborder="0" style="border-radius: 4px;"></iframe>

import win32com . client

# 创建 AutoCAD 应用程序对象

acad = win32com . client . Dispatch ( "AutoCAD.Application" )

# 获取活动文档

doc = acad .ActiveDocument

# 清除可能已经存在的同名选择集

try :

    doc .SelectionSets.Item( "MySelection" ).Delete()

except :

    pass

# 选择一个文字对象

selection = doc .SelectionSets.Add( "MySelection" )

selection .Clear()

selection .SelectOnScreen()

for obj in selection : # 遍历选择集中的对象

    if obj .ObjectName == "AcDbText" :

        obj .TextString = "A-" + obj .TextString

        obj .color = 3

selection .Clear() # 清除选择集

微信号

网盘地址:http://52cad.ysepan.com/

备用网盘:https://www.123pan.com/s/yCfbVv-LIeh3.html密码:5201

点赞关注我哦,以后小编为大家推荐更多

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐