明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 654|回复: 3

[提问] CAD 注释比例列表是从哪儿重置的?

[复制链接]
发表于 2024-11-28 12:59:05 | 显示全部楼层 |阅读模式
CAD注释比例列表是从哪儿重置的?能从源头去修改吗?

本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
回复

使用道具 举报

发表于 2024-11-28 16:31:55 | 显示全部楼层
表示不知道
回复 支持 反对

使用道具 举报

发表于 2024-11-30 15:15:34 | 显示全部楼层
在cad支持路径下的“acad20**doc.lsp”末尾添加下一行文字,保存关闭,重启对应cad即可。
(command "-scalelistedit" "reset" "y" "e")

----------------
或者在命令行执行一下以下命令:
命令: -scalelistedit
输入选项 [?/添加(A)/删除(D)/重置(R)/退出(E)] <添加>: r
要将比例列表重置为默认值吗?[是(Y)/否(N)] <否>: y
回复 支持 反对

使用道具 举报

 楼主| 发表于 5 天前 | 显示全部楼层
1、添加比例

  1.    <CommandMethod("AddScale")>
  2.    Public Shared Sub addScale()
  3.        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
  4.        Dim db As Database = doc.Database
  5.        ' next get the objectContextManager           
  6.        Try
  7.            Dim contextManager As ObjectContextManager = db.ObjectContextManager
  8.            ' if ok               
  9.            If contextManager IsNot Nothing Then
  10.                ' now get the Annotation Scaling context collection
  11.                ' (named ACDB_ANNOTATIONSCALES_COLLECTION)                  
  12.                Dim contextCollection As ObjectContextCollection = contextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
  13.                ' if ok                  
  14.                If contextCollection IsNot Nothing Then
  15.                    ' create a brand new scale context                       
  16.                    Dim annotationScale As New AnnotationScale With {
  17.                        .Name = "WBScale2 1:28",
  18.                        .PaperUnits = 1,
  19.                        .DrawingUnits = 28
  20.                    }
  21.                    ' now add to the drawing's context collection                       
  22.                    contextCollection.AddContext(annotationScale)
  23.                End If
  24.            End If
  25.        Catch ex As System.Exception
  26.            Dim ed As Editor = doc.Editor
  27.            ed.WriteMessage(ex.ToString())
  28.        End Try
  29.    End Sub
代码转自:https://adndevblog.typepad.com/a ... e-to-a-drawing.html

2:删除英制比例等
  1. <CommandMethod("DelScale")>
  2. Public Shared Sub DelScale()
  3.     Dim doc As Document = Application.DocumentManager.MdiActiveDocument
  4.     Dim db As Database = doc.Database
  5.     ' next get the objectContextManager           
  6.     Try
  7.         Dim contextManager As ObjectContextManager = db.ObjectContextManager
  8.         ' if ok               
  9.         If contextManager IsNot Nothing Then
  10.             ' now get the Annotation Scaling context collection
  11.             ' (named ACDB_ANNOTATIONSCALES_COLLECTION)                  
  12.             Dim contextCollection As ObjectContextCollection = contextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
  13.             ' if ok                  
  14.             If contextCollection IsNot Nothing Then
  15.                 For Each objectContext As ObjectContext In contextCollection
  16.                     If TypeOf objectContext Is AnnotationScale Then
  17.                         Dim Name As String = objectContext.Name
  18.                         If Name.Contains("=") Then
  19.                             '删除英制比例,比如: 1/128" = 1'-0"
  20.                             contextCollection.RemoveContext(Name)
  21.                         End If
  22.                         If Name.Contains(":") Then
  23.                             '删除公制比例中的2:1、4:1、8:1、10:1等
  24.                             Dim Start As String = Name.Split(":")(0)
  25.                             If Start <> "1" Then
  26.                                 contextCollection.RemoveContext(Name)
  27.                             End If
  28.                         End If
  29.                     End If
  30.                 Next
  31.             End If
  32.         End If
  33.     Catch ex As System.Exception
  34.         Dim ed As Editor = doc.Editor
  35.         ed.WriteMessage(ex.ToString())
  36.     End Try
  37. End Sub
3、清理比例
  1. <CommandMethod("PuScale")>
  2. Public Shared Sub PuScale()
  3.      Dim doc As Document = Application.DocumentManager.MdiActiveDocument
  4.      Dim db As Database = doc.Database
  5.      Try
  6.          Using acTr As Transaction = db.TransactionManager.StartTransaction()
  7.              Dim objectIdCollection As New ObjectIdCollection()
  8.              Dim objectContextManager As ObjectContextManager = db.ObjectContextManager
  9.              If objectContextManager IsNot Nothing Then
  10.                  Dim contextCollection As ObjectContextCollection = objectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
  11.                  If contextCollection IsNot Nothing Then
  12.                      For Each objectContext As ObjectContext In contextCollection
  13.                          If TypeOf objectContext Is AnnotationScale Then
  14.                              objectIdCollection.Add(New ObjectId(objectContext.UniqueIdentifier))
  15.                          End If
  16.                      Next
  17.                  End If
  18.              End If
  19.              db.Purge(objectIdCollection)

  20.              For Each obj As Object In objectIdCollection
  21.                  Dim objectId As ObjectId = CType(obj, ObjectId)
  22.                  acTr.GetObject(objectId, OpenMode.ForWrite).[Erase]()
  23.              Next

  24.              acTr.Commit()
  25.          End Using

  26.      Catch ex As System.Exception
  27.          Dim ed As Editor = doc.Editor
  28.          ed.WriteMessage(ex.ToString())
  29.      End Try
  30. End Sub


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-4-18 12:15 , Processed in 0.173934 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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