tiancao100 发表于 2024-11-28 12:59:05

CAD 注释比例列表是从哪儿重置的?

CAD注释比例列表是从哪儿重置的?能从源头去修改吗?

你有种再说一遍 发表于 2024-11-28 16:31:55

表示不知道

aichong 发表于 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

tiancao100 发表于 2025-4-13 11:07:41

1、添加比例

   <CommandMethod("AddScale")>
   Public Shared Sub addScale()
       Dim doc As Document = Application.DocumentManager.MdiActiveDocument
       Dim db As Database = doc.Database
       ' next get the objectContextManager         
       Try
         Dim contextManager As ObjectContextManager = db.ObjectContextManager
         ' if ok               
         If contextManager IsNot Nothing Then
               ' now get the Annotation Scaling context collection
               ' (named ACDB_ANNOTATIONSCALES_COLLECTION)                  
               Dim contextCollection As ObjectContextCollection = contextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
               ' if ok                  
               If contextCollection IsNot Nothing Then
                   ' create a brand new scale context                     
                   Dim annotationScale As New AnnotationScale With {
                     .Name = "WBScale2 1:28",
                     .PaperUnits = 1,
                     .DrawingUnits = 28
                   }
                   ' now add to the drawing's context collection                     
                   contextCollection.AddContext(annotationScale)
               End If
         End If
       Catch ex As System.Exception
         Dim ed As Editor = doc.Editor
         ed.WriteMessage(ex.ToString())
       End Try
   End Sub代码转自:https://adndevblog.typepad.com/autocad/2012/05/using-the-net-api-to-add-a-scale-to-a-drawing.html

2:删除英制比例等
<CommandMethod("DelScale")>
Public Shared Sub DelScale()
    Dim doc As Document = Application.DocumentManager.MdiActiveDocument
    Dim db As Database = doc.Database
    ' next get the objectContextManager         
    Try
      Dim contextManager As ObjectContextManager = db.ObjectContextManager
      ' if ok               
      If contextManager IsNot Nothing Then
            ' now get the Annotation Scaling context collection
            ' (named ACDB_ANNOTATIONSCALES_COLLECTION)                  
            Dim contextCollection As ObjectContextCollection = contextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
            ' if ok                  
            If contextCollection IsNot Nothing Then
                For Each objectContext As ObjectContext In contextCollection
                  If TypeOf objectContext Is AnnotationScale Then
                        Dim Name As String = objectContext.Name
                        If Name.Contains("=") Then
                            '删除英制比例,比如: 1/128" = 1'-0"
                            contextCollection.RemoveContext(Name)
                        End If
                        If Name.Contains(":") Then
                            '删除公制比例中的2:1、4:1、8:1、10:1等
                            Dim Start As String = Name.Split(":")(0)
                            If Start <> "1" Then
                              contextCollection.RemoveContext(Name)
                            End If
                        End If
                  End If
                Next
            End If
      End If
    Catch ex As System.Exception
      Dim ed As Editor = doc.Editor
      ed.WriteMessage(ex.ToString())
    End Try
End Sub3、清理比例
<CommandMethod("PuScale")>
Public Shared Sub PuScale()
   Dim doc As Document = Application.DocumentManager.MdiActiveDocument
   Dim db As Database = doc.Database
   Try
         Using acTr As Transaction = db.TransactionManager.StartTransaction()
             Dim objectIdCollection As New ObjectIdCollection()
             Dim objectContextManager As ObjectContextManager = db.ObjectContextManager
             If objectContextManager IsNot Nothing Then
               Dim contextCollection As ObjectContextCollection = objectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES")
               If contextCollection IsNot Nothing Then
                     For Each objectContext As ObjectContext In contextCollection
                         If TypeOf objectContext Is AnnotationScale Then
                           objectIdCollection.Add(New ObjectId(objectContext.UniqueIdentifier))
                         End If
                     Next
               End If
             End If
             db.Purge(objectIdCollection)

             For Each obj As Object In objectIdCollection
               Dim objectId As ObjectId = CType(obj, ObjectId)
               acTr.GetObject(objectId, OpenMode.ForWrite).()
             Next

             acTr.Commit()
         End Using

   Catch ex As System.Exception
         Dim ed As Editor = doc.Editor
         ed.WriteMessage(ex.ToString())
   End Try
End Sub

页: [1]
查看完整版本: CAD 注释比例列表是从哪儿重置的?