博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VBNET AutoCAD Activex 切换图层为当前图层失效
阅读量:5035 次
发布时间:2019-06-12

本文共 3005 字,大约阅读时间需要 10 分钟。

最近有朋友询问切换图层的代码

com切换图层

 

1 
2 Public Sub MySubLayerChange() 3 Dim Thisdrawing As Autodesk.AutoCAD.Interop.AcadDocument = Application.DocumentManager.MdiActiveDocument.AcadDocument 4 Dim curLayer As Autodesk.AutoCAD.Interop.Common.AcadLayer = Thisdrawing.ActiveLayer 5 Dim newLayer As Autodesk.AutoCAD.Interop.Common.AcadLayer 6 For Each la As Autodesk.AutoCAD.Interop.Common.AcadLayer In Thisdrawing.Layers 7 If la.Name = "layer1" Then 8 newLayer = la 9 Thisdrawing.ActiveLayer = newLayer10 End If11 Next12 13 End Sub
View Code

 

示效的话用下面的代码,切换系统变量

 

1 Public Sub ChangeLayer(ByRef LayerName As String) 2  3         Acadapp.ActiveDocument.SetVariable("Clayer", LayerName) 4         Acadapp.ActiveDocument.SetVariable("CELTYPE", "Bylayer") 5  6         'For Each entry As Object In Acadapp.ActiveDocument.layers 7         '    If entry.name = LayerName Then 8         '        Acadapp.ActiveDocument.Activelayer = entry 9         '        Exit For10         '    End If11         'Next entry12 13         ''改变线型14         'For Each entry As Object In Acadapp.ActiveDocument.Linetypes15         '    If entry.name = "Bylayer" Then16         '        Acadapp.ActiveDocument.ActiveLinetype = entry17         '        Exit For18         '    End If19         'Next20 21     End Sub22     '改变标注样式 //20190606 nan sheng modify 23     Public Sub ChangeDimStyles(ByRef Name As String)24         Acadapp.ActiveDocument.SendCommand("-dimstyle" & vbCr & "r" & vbCr & Name & vbCr) REM "_zoom" & vbCr & "a" & vbCr25         'ThisDrawing.SendCommand ("-dimstyle" & vbCr & "r" & vbCr & "111" & vbCr)26         'For Each entry As Object In Acadapp.ActiveDocument.DimStyles27         '    If entry.name = Name Then28         '        Acadapp.ActiveDocument.ActiveDimStyle = entry29         '        Exit For30         '    End If31         'Next entry32     End Sub33 34     '改变文字样式//20190606 nan sheng modify 35     Public Sub ChangeTextStyles(ByRef Name As String)36         Acadapp.ActiveDocument.SetVariable("TEXTSTYLE", Name)37         'For Each entry As Object In Acadapp.ActiveDocument.TextStyles38         '    If entry.name = Name Then39         '        Acadapp.ActiveDocument.ActiveTextStyle = entry40         '        Exit For41         '    End If42         'Next entry43     End Sub
View Code

 

NetApi切换图层

 

1 
2 Public Sub MySubLayerChangeNetApi() 3 Dim doc As Document = Application.DocumentManager.MdiActiveDocument 4 Dim db As Database = doc.Database 5 Using trans As Transaction = db.TransactionManager.StartTransaction() 6 Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead) 7 If lt.Has("layer1") Then 8 db.Clayer = lt("layer1") 9 End If10 trans.Commit()11 End Using12 13 End Sub
View Code

 

转载于:https://www.cnblogs.com/NanShengBlogs/p/10988190.html

你可能感兴趣的文章
前端基础之JavaScript
查看>>
导航网格寻路之点哪走哪
查看>>
[19/04/09-星期二] 多线程_线程同步
查看>>
亲测SQLServer的最大连接数
查看>>
华为手机权限开启方法4
查看>>
(hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C
查看>>
新概念 Lesson 3 Nice to meet you
查看>>
第一次JAVA作业
查看>>
POJ-3041 Asteroids 二分图匹配
查看>>
HDU-1280 前m大的数
查看>>
redis基本指令
查看>>
制作动态链接库
查看>>
Frame 处理
查看>>
读代码
查看>>
pythonweb框架Flask学习笔记02-一个简单的小程序
查看>>
火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法
查看>>
NSThread创建方式
查看>>
Hadoop+Spark+Hbase部署整合篇
查看>>
Android基础类之BaseAdapter
查看>>
Pagerank
查看>>