看看下面的资料,关于处理NAMED PAGE的VLISP,VBA的方法,借鉴下,删除NAMED PAGE 设置,秋风,你的程序写好后,贴到论坛来。
DELETING A NAMED PAGE SETUP
ID 65115
Applies to: AutoCAD 2000
AutoCAD 2000I
Date 2/19/2002
This document is part of AutoCAD Visual Lisp Dictionaries Plotting VBA
Question
How to delete a named page setup using LISP or VBA?
Answer
You can use Visual Lisp or VBA to delete page setups from the ACAD_PLOTSETTINGS
dictionary. Both the examples below will delete all page setups, so it may
be beneficial to add a prompt or alert for the user.

- [FONT=courier new]
- ;;;Visual Lisp example:
- (defun C:DelPgSetups ( / appAcad colPgSetups docCurrent objPgSetup)
- (vl-load-com)
- (setq appAcad (vlax-get-acad-object) ;get the ACAD application object
- docCurrent (vla-get-ActiveDocument appAcad) ;get the current drawing
- ;;get the ACAD_PLOTSETTINGS dictionary
- colPgSetups (vla-get-PlotConfigurations docCurrent)
- ) ;setq
- ;;get each page setup in the ACAD_PLOTSETTINGS dictionary
- (vlax-for objPgSetup colPgSetups
- (princ (strcat "\nDeleting " (vla-get-name objPgSetup) "..."))
- (vla-delete objPgSetup) ;delete the page setup from the dictionary
- (vlax-release-object objPgSetup) ;release the page setup
- );vlax-for
- (princ "\n\nDone.")
- ;;release objects from memory
- (vlax-release-object colPgSetups)
- (vlax-release-object docCurrent)
- (vlax-release-object appAcad)
- (princ)
- );End of defun DelPgSetups
- 'VBA Example:
- Public Sub DelPgSetups()
- Dim colPltConfig As AcadPlotConfigurations
- Dim objPltConfig As AcadPlotConfiguration
- Set colPltConfig = ThisDrawing.PlotConfigurations
- For Each objPltConfig In colPltConfig
- ThisDrawing.Utility.Prompt "Deleting " & objPltConfig.Name & "..." & vbCrLf
- objPltConfig.Delete
- Next objPltConfig
- ThisDrawing.Utility.Prompt vbCrLf & "Done" & vbCrLf
- End Sub
- [/FONT]
|