明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: vampire

[编程申请]不管当前层是什么,所有标注都放在特定的层里

  [复制链接]
发表于 2007-10-23 13:00:00 | 显示全部楼层

提供自动切换图层的程序就可以实现 

本论坛有提供,好像是用VBA开发的,不过我没有用过

图层自动切换程序 V2

我用lisp也开发了一个,因为时间原因还有不是问题需要完善,以后有机会发上来。

发表于 2007-11-26 22:44:00 | 显示全部楼层

等待中

发表于 2007-11-28 08:22:00 | 显示全部楼层

其实做这个最好是用VBA,当然,用LISP也是可以的,不过代码相对可参较长,我把我做的一个提供给大家做参考,当然,如果要在R14下用,可能还得安装VBA系统。

放到Thisdrawing的代码里面。

Option Explicit
Dim Clay As String

Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
On Error Resume Next
Dim tt As String
Dim Tmply As String
'Debug.Print CommandName
    Select Case LCase(CommandName)
Case "bhatch"

    Tmply = ThisDrawing.GetVariable("clayer")
    If LCase(Tmply) <> "han" Or Clay = "" Then
        'ThisDrawing.SetVariable "clayer", Clay
        Clay = ThisDrawing.GetVariable("clayer")
    End If
    ThisDrawing.Layers.Add "han"
    ThisDrawing.SetVariable "clayer", "han"
Case "dimlinear", "dimaligned", "dimordinate", "dimradius", "dimdiameter", "dimangular", "qdim", "dimbaseline", "dimcontinue"
   
    Clay = ThisDrawing.GetVariable("clayer")
    ThisDrawing.Layers.Add "dim"
    ThisDrawing.SetVariable "clayer", "dim"
Case "text", "mtext"
    Clay = ThisDrawing.GetVariable("clayer")
    Select Case LCase(Clay)
        Case "vbtk", "mxbdata", "vbjsxn", "label"
            DoEvents
        Case Else
       
            ThisDrawing.Layers.Add "02c"
            ThisDrawing.SetVariable "clayer", "02c"
    End Select
'唉,不好办,我的明细表,画图框都要写文字,而又不能放到02c。
Case Else
    Tmply = ThisDrawing.GetVariable("clayer")
    If LCase(Tmply) = "han" Then
        If Clay <> "" Then
            ThisDrawing.SetVariable "clayer", Clay
            Clay = ""
        End If
    ElseIf Tmply = "0" Then
        ThisDrawing.Layers.Add "01"
        ThisDrawing.SetVariable "clayer", "01"
   
    End If
End Select

End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
On Error Resume Next
Select Case LCase(CommandName)
    Case "bhatch", "dimlinear", "dimaligned", "dimordinate", "dimradius", "dimdiameter", "dimangular", "qdim", "dimbaseline", "dimcontinue", "text", "mtext"
        ThisDrawing.SetVariable "clayer", Clay
        Clay = ""
End Select

End Sub

发表于 2008-4-1 12:42:00 | 显示全部楼层

网上找的!您把里面的41层改为您要的标注层就OK!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2008-4-7 13:19:00 | 显示全部楼层
可以用VBA的事件来控制,以前编过一个类似的,不过感觉意义不是很大,扔掉了
发表于 2008-7-24 21:44:00 | 显示全部楼层

可以用VBA的 begincommand()方法,当调用指定的命令前执行相应的程序

endcommand()方法也好用,我以前写过,能用,后来忘记扔那去了,

发表于 2008-8-17 00:03:00 | 显示全部楼层
燕秀工具箱有这个把所有标注归入标注层呀
发表于 2008-8-31 09:47:00 | 显示全部楼层
autolayer[3.0].lsp
发表于 2008-9-1 19:47:00 | 显示全部楼层
感觉附件里的东西不错,谢谢14楼的兄弟
发表于 2008-11-1 23:53:00 | 显示全部楼层
谢谢分享!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-27 20:51 , Processed in 0.165596 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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