CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于 AutoCAD 如何保存图层设置 (VBA/ActiveX)

2023-1-4 23:32| 发布者: admin| 查看: 1656| 评论: 0|来自: AutoCAD

摘要: AutoCAD 将图层设置信息保存在图形的“图层”集合的扩展字典中。

AutoCAD 将图层设置信息保存在图形集合的扩展字典中。Layers

首次在图形中保存图层设置时,AutoCAD 将执行以下操作:

  • 在集合中创建扩展字典。Layers
  • 在扩展字典中创建名为 ACAD_LAYERSTATE 的对象。Dictionary
  • 将图形中每个图层的特性存储在ACAD_LAYERSTATE字典中的对象中。AutoCAD 将所有图层设置存储在 中,但标识您选择保存的特定设置。恢复图层设置时,AutoCAD 仅恢复您选择保存的设置。XRecordXRecord

每次在图形中保存其他图层设置时,AutoCAD 都会创建另一个描述已保存设置的对象,并将其存储在ACAD_LAYERSTATE字典中。下图说明了该过程。XRecordXRecord



使用 ActiveX 处理图层设置时,您不需要(也不应尝试)进行解释。使用对象的函数访问保存的图层设置。XRecordsLayerStateManager

列出图形中保存的图层设置

如果图层设置已保存在当前图形中,则以下代码将列出所有已保存图层设置的名称:

Sub Ch4_ListStates()
  On Error Resume Next

  Dim oLSMDict As AcadDictionary
  Dim XRec As Object
  Dim layerstateNames As String
  layerstateNames = ""

  ' Get the ACAD_LAYERSTATES dictionary, which is in the
  ' extension dictionary in the Layers object.
  Set oLSMDict = ThisDrawing.Layers.GetExtensionDictionary.Item("ACAD_LAYERSTATES")

  ' List the name of each saved layer setting. Settings are
  ' stored as XRecords in the dictionary.
  For Each XRec In oLSMDict
   layerstateNames = layerstateNames + XRec.Name + vbCrLf
  Next XRec
  MsgBox "The saved layer settings in this drawing are: " + vbCrLf + layerstateNames
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 13:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部