明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1970|回复: 2

[例程]图层操作:添加图层、获取图层、切换图层

[复制链接]
发表于 2002-5-28 21:03:00 | 显示全部楼层 |阅读模式
Public Sub UseLayer()

Dim layObj As AcadLayer
Set layObj = ThisDrawing.Layers.Add("testLayer")

End Sub

Public Sub GetLayer()

Dim layName As String
'Set layObj = ThisDrawing.Layers.Item(1)
'Set layObj = ThisDrawing.Layers.Item("testLayer")
'Set layObj = ThisDrawing.Layers(1)
Set layObj = ThisDrawing.Layers("testLayer")

layName = layObj.Name
MsgBox "层名称为:" & layName

MsgBox "层的数量:" & ThisDrawing.Layers.Count

End Sub

Public Sub LayerChange()
    Dim cirObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
   
    center(0) = 256: center(1) = 182: center(2) = 0
    radius = 38
    Set cirObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

    MsgBox "现在圆所在的层为:" & cirObj.Layer
   
    Dim newLayer As AcadLayer
    Set newLayer = ThisDrawing.Layers("Layer1")
    cirObj.Layer = "Layer1"
   
    MsgBox "现在圆所在的层为:" & cirObj.Layer
   
    newLayer.Freeze = True
   
End Sub
 楼主| 发表于 2002-5-28 21:06:00 | 显示全部楼层

[例程]图层操作:切换当前层、图层打开关闭、冻结解冻、锁定解锁、重命名、删除

Public Sub UseLayer()

Dim layObj As AcadLayer
Set layObj = ThisDrawing.Layers.Add("testLayer")

End Sub

Public Sub GetLayer()

Dim layName As String
'Set layObj = ThisDrawing.Layers.Item(1)
'Set layObj = ThisDrawing.Layers.Item("testLayer")
'Set layObj = ThisDrawing.Layers(1)
Set layObj = ThisDrawing.Layers("testLayer")

layName = layObj.Name
MsgBox "层名称为:" & layName

MsgBox "层的数量:" & ThisDrawing.Layers.Count

End Sub

Public Sub LayerChange()
    Dim cirObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
   
    center(0) = 256: center(1) = 182: center(2) = 0
    radius = 38
    Set cirObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

    MsgBox "现在圆所在的层为:" & cirObj.Layer
   
    Dim newLayer As AcadLayer
    Set newLayer = ThisDrawing.Layers("Layer1")
    cirObj.Layer = "Layer1"
   
    MsgBox "现在圆所在的层为:" & cirObj.Layer
   
    newLayer.Freeze = True
   
End Sub
发表于 2006-6-14 16:31:00 | 显示全部楼层
图层操作中能不设定为某一个图层不打印?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 02:22 , Processed in 0.158524 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表