关于使用命名视图 (ActiveX)
您可以命名和保存要重用的视图。当您不再需要该视图时,可以将其删除。
若要创建新视图,请使用该方法将新视图添加到集合中。保存图形时,将保存视图的查看位置和比例。AddViews
您可以在创建视图时为其命名。视图的名称长度最多为 255 个字符,包含字母、数字和特殊字符美元符号 ($)、连字符 (-) 和下划线 (_)。
若要删除命名视图,只需使用该方法即可。对象的方法位于对象上,而不是其父对象上。DeleteDeleteViewView
添加 View 对象
下面的示例添加一个对象 (viewObj)。View
- AutoLISP
-
(vl-load-com)
(defun c:Ch3_AddView()
;; Add a named view to the views collection
(setq acadObj (vlax-get-acad-object)
doc (vla-get-ActiveDocument acadObj)
viewsCollection (vla-get-Views doc)
viewObj (vla-Add viewsCollection "View1"))
)
- VBA(仅限 AutoCAD)
-
Sub Ch3_AddView()
' Add a named view to the views collection
Dim viewObj As AcadView
Set viewObj = ThisDrawing.Views.Add("View1")
End Sub
删除 View 对象
以下示例删除对象 (viewObj)。View
- AutoLISP
-
(vl-load-com)
(defun c:Ch3_DeleteView()
(setq acadObj (vlax-get-acad-object)
doc (vla-get-ActiveDocument acadObj)
viewsCollection (vla-get-Views doc)
viewObj (vla-Item viewsCollection "View1"))
;; Delete the view
(vla-Delete viewObj)
)
- VBA(仅限 AutoCAD)
-
Sub Ch3_DeleteView()
Dim viewObj As AcadView
Set viewObj = ThisDrawing.Views("View1")
' Delete the view
viewObj.Delete
End Sub
从 Views 集合中删除命名视图
本示例从集合中删除命名视图。Views
- AutoLISP
-
(vl-load-com)
(defun c:Ch3_DeleteViewFromCollection()
(setq acadObj (vlax-get-acad-object)
doc (vla-get-ActiveDocument acadObj)
viewsCollection (vla-get-Views doc))
(vla-Delete (vla-Item viewsCollection "View1"))
)
- VBA(仅限 AutoCAD)
-
Sub Ch3_DeleteViewFromCollection()
ThisDrawing.Views("View1").Delete
End Sub
|