当前位置:网站首页>ArcGIS Pro脚本工具(6)——修复CAD图层数据源
ArcGIS Pro脚本工具(6)——修复CAD图层数据源
2022-06-30 09:37:00 【学点GIS】
Pro对CAD文件的支持显而易见的优于ArcMap。虽然都是将CAD识别成点、线、面、多面体和注记5大类,但是当我们拖动其中一类到Pro中时,Pro自动将其分图层显示,并且图层的颜色与CAD一致。nice!
但是尴尬的是,一旦CAD文件移动了位置或者改了名字,就是一长列的红色惊叹号警告。有经验的使用者可能期望修复一个图层后,其他图层自动修复,但是很可惜这对这些CAD图层无效。
那我重新拖CAD进来不就成了?可能不太行,因为已经在Pro里改过一些图层的符号系统了,重新拖CAD进来就得重新做很多图层的符号系统,太麻烦了。
针对不同的情况,有不同的解决办法。
1、CAD文件位置改变,文件名不变
这种情况下,比较方便的办法是打开 目录视图-目录选项卡-数据源-工作空间,选择CAD图层组,新路径中填入CAD文件现在的位置,点击应用,完成。
2、CAD文件位置和文件名都已经改变
解决办法比上面多出一步,就是需要先更新CAD文件名。还是考虑使用脚本工具来实现。
Python脚本
import os
import arcpy
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
m = aprx.activeMap
groupLayer = arcpy.GetParameterAsText(0)
lyrs = m.listLayers()
cad = arcpy.GetParameterAsText(1)
cad_name = os.path.basename(cad)
cad_path = os.path.dirname(cad)
cp = {'workspace_factory': 'Cad', 'connection_info': {'database': cad_path}}
for lyr in lyrs:
longName = lyr.longName
if longName.startswith(groupLayer) and lyr.isGroupLayer==False:
lyrCIM = lyr.getDefinition("V2")
dc = lyrCIM.featureTable.dataConnection
# Update the feature dataset with the new CAD file name
dc.featureDataset = cad_name
# Update layer CIM
lyr.setDefinition(lyrCIM)
lyr.updateConnectionProperties(lyr.connectionProperties, cp)
sym=lyr.symbology
color=sym.renderer.symbol.color
color['RGB'][3]=100
sym.renderer.symbol.color=color
lyr.symbology=sym
arcpy.AddMessage('已修复 '+lyr.name)
参数设置
运行演示
模型说明
除了修复CAD图层的数据源外,脚本工具也取消了所有CAD图层的面符号的透明度,方便在外观选项卡上统一调整。
边栏推荐
- AttributeError: ‘Version‘ object has no attribute ‘major‘
- Curl --- the request fails when the post request parameter is too long (more than 1024b)
- Leetcode question brushing (III) -- binary search (go Implementation)
- ‘Failed to fetch current robot state‘ when using the ‘plan_kinematic_path‘ service #868
- The digital collection of sunanmin's lotus heart clearing was launched on the Great Wall Digital Art
- MySQL advanced SQL statement of database (1)
- Splendid China: public welfare tourism for the middle-aged and the elderly - entering Foshan nursing home
- Memorize the text and remember the words. Read the text and remember the words. Read the article and remember the words; 40 articles with 3500 words; 71 articles broke through the words in the middle
- What is the real performance of CK5, the king machine of CKB?
- [ark UI] implementation of the startup page of harmoniyos ETS
猜你喜欢
Eth is not connected to the ore pool
Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect
Didn't receive robot state (joint angles) with recent timestamp within 1 seconds
华南产业集团发力数字经济,城链科技发布会成功召开
GNN动手实践(二):复现图注意力网络GAT
Robot system dynamics - inertia parameters
Deployment of efficient and versatile clusters lvs+kept highly available clusters
Harvester ch1 of CKB and HNS, connection tutorial analysis
孙安民作品《莲花净心》数字藏品上线长城数艺
Rider打开Unity脚本后没有提示
随机推荐
‘Failed to fetch current robot state‘ when using the ‘plan_kinematic_path‘ service #868
How does the diode work?
背课文记单词,读课文记单词,读文章记单词;40篇文章搞定3500词;71篇文章突破中考单词;15篇文章贯通四级词汇;15篇文章贯通六级词汇
6.Redis新数据类型
MIT-6874-Deep Learning in the Life Sciences Week6
"Kunming City coffee map" activity was launched again
Tooltips in the era of touch
UAV project tracking record 83 -- PCB diagram completion
6. Redis new data type
半钢同轴射频线的史密斯圆图查看和网络分析仪E5071C的射频线匹配校准
train_ de.py: error: argument --save_ steps: invalid int value: ‘$[$[889580/128/4]*10/2]‘
Dyson design award, changing the world with sustainable design
Koreano essential creates a professional style
Js獲取指定字符串指定字符比特置&指定字符比特置區間的子串【簡單詳細】
JS get the substring of the specified character position and the specified character position interval of the specified string [simple and detailed]
开源了!文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开
"Kunming City coffee map" activity was launched again
Brève description du collecteur d'ordures G1
Koreano essential creates a professional style
Description of event object