AutoCAD VBA基于对象的分层
AutoCAD VBA基于對象的分層,講不同對象根據特性分層,代碼如下。
Dim Value As Variant
Value = ThisDrawing.GetVariable("cmdecho")
ThisDrawing.SetVariable "cmdecho", 0
Dim ObjLayer As AcadLayer
Set ObjLayer = ThisDrawing.Layers.Add("尺寸標注")
Set ObjLayer = ThisDrawing.Layers.Add("文字")
Set ObjLayer = ThisDrawing.Layers.Add("主體")
Set ObjLayer = ThisDrawing.Layers.Add("圖案填充")
Set ObjLayer = ThisDrawing.Layers.Add("虛線")
Set ObjLayer = ThisDrawing.Layers.Add("中心線")
Set ObjLayer = ThisDrawing.Layers.Add("剖面線")
Set ObjLayer = ThisDrawing.Layers.Add("隱藏線")
Dim ObjSelectionSet As AcadSelectionSet
Dim Count As Integer
Count = ThisDrawing.SelectionSets.Count
While (Count > 0)
Set ObjSelectionSet = ThisDrawing.SelectionSets.Item(Count - 1)
ObjSelectionSet.Delete
Count = Count - 1
Wend
Set ObjSelectionSet = ThisDrawing.SelectionSets.Add("SSET")
Dim gpCode() As Integer
Dim dataValue() As Variant
ReDim gpCode(0)
ReDim dataValue(0)
Mode = acSelectionSetAll
gpCode(0) = 0
dataValue(0) = "dimension"
Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue
ObjSelectionSet.Select Mode, , , groupCode, dataCode
Dim tntry As AcadEntity
For Each tntry In ObjSelectionSet
Entry.Layer = "尺寸標注"
Entry.Update
Next Entry
ObjSelectionSet.Clear
gpCode(0) = 0
dataValue(0) = "text"
groupCode = gpCode
dataCode = dataValue
ObjSelectionSet.Select Mode, , , groupCode, dataCode
For Each Entry In ObjSelectionSet
Entry.Layer = "文字"
Entry.Update
Next Entry
ObjSelectionSet.Clear
ObjSelectionSet.Delete
ThisDrawing.SetVariable "cmdecho", scmde
代碼完。
總結
以上是生活随笔為你收集整理的AutoCAD VBA基于对象的分层的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 入门基础-VC网络编程入门
- 下一篇: ITU-R BT.656 协议