明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: gjliang

[求助]请帮我看以下这段代码

  [复制链接]
发表于 2003-11-21 13:49:00 | 显示全部楼层
搞不清你想问些什么内容,按照你的图,GZY已经帮你解决了问题。
 楼主| 发表于 2003-11-21 15:07:00 | 显示全部楼层
是的,我贴错内容了,把那个我改过的没问题的贴出来了,对不起啊
发表于 2003-11-21 15:11:00 | 显示全部楼层
改好了,代码如下:
Sub wm()
Dim ent As AcadEntity
Dim tet As String
ThisDrawing.Utility.InitializeUserInput 0, "k a"
tet = ThisDrawing.Utility.GetKeyword _
(vbCrLf & "输入选项[框选(k)/全图(a)](a): ")
If tet = "" Or Err Then tet = "a"
    If tet = "a" Then
        For Each ent In ThisDrawing.ModelSpace
                If ent.Linetype = "ACAD_ISO05W100" Then
                ' On Error Resume Next
                Dim layc As AcadLayer
                Set layc = ThisDrawing.Layers.Add("粗实线")
                layc.color = acWhite
                layc.Lineweight = acLnWt050
                ent.Layer = "粗实线"
                ent.color = acByLayer
                ent.Lineweight = acLnWtByLayer
                ent.Linetype = "ACAD_ISO05W100"
                End If
        Next
    End If
If tet = "k" Then
Dim ss As AcadSelectionSet
Set ss = GetSelSet
    For Each ent In ss
     If ent.Linetype = "ACAD_ISO05W100" Then
                ' On Error Resume Next
                Dim layc1 As AcadLayer
                Set layc1 = ThisDrawing.Layers.Add("粗实线")
                layc1.color = acWhite
                layc1.Lineweight = acLnWt050
                ent.Layer = "粗实线"
                ent.color = acByLayer
                ent.Lineweight = acLnWtByLayer
                ent.Linetype = "ACAD_ISO05W100"
                End If
    Next
End If
ThisDrawing.PurgeAll
End Sub
Function GetSelSet() As AcadSelectionSet
    Dim ss As AcadSelectionSet
    Dim ssName As String
    ssName = "ICKFIRST"
    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets.Add(ssName)
    If Err Then
        Set ss = ThisDrawing.SelectionSets(ssName)
        ss.Delete
    End If
    Set ss = ThisDrawing.PickfirstSelectionSet
    If ss.Count = 0 Then
Set ss = ThisDrawing.SelectionSets(ssName)
        If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
        ss.Clear
        ss.SelectOnScreen
    End If
    Set GetSelSet = ss
    ThisDrawing.SetVariable "filedia", 1
End Function
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 13:46 , Processed in 0.149275 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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