你不需要“活动窗口”的东西;这不是脚本。
“ThisDrawing”很简单,是默认值,但在处理多个图形时,您可以并且应该使用自己的变量名。
创建新的DWG文件时,应为其设置一个变量,并使用该变量对其进行引用;类似这样:
- Sub main()
- Dim FirstDwg As AcadDocument
- Dim SecondDwg As AcadDocument
- ' set the variable "FirstDwg" to some drawing you opened from disk:
- Set FirstDwg = Application.Documents.Open("c:\MyTestDwg.dwg", False)
- ' set the variable "SecondDwg" to a drawing you create new:
- Set SecondDwg = Application.Documents.Add()
- ' activate the first drawing and zoom extents
- FirstDwg.Activate: ZoomExtents
- ' Pop up the name of the active layer, in the second drawing, without activating it
- MsgBox SecondDwg.ActiveLayer.Name
- ' clear the Object variables before leaving the sub
- Set FirstDwg = Nothing
- Set SecondDwg = Nothing
- End Sub
|