在VBA中使用PickfirstSelectionSet选择集的方法,在本论坛已经被讨论过了。在我的程序中因要利用PickfirstSelectionSet选择集,就按这些方法试了试。发现仅调用一次PickfirstSelectionSet选择集时,没有问题。但当多次调用PickfirstSelectionSet选择集时,还是有错误发生。不知道为什么? 程序如下: Option Explicit Public Sub PFSS() Dim ssetObj As AcadSelectionSet Dim obj As AcadObject Set ssetObj = PickFirstSSet If Not (ssetObj Is Nothing) Then For Each obj In ssetObj obj.Delete Next MsgBox ssetObj.Count & " object(s) deleted" End If End Sub Function PickFirstSSet() As AcadSelectionSet On Error Resume Next ThisDrawing.SelectionSets("PICKFIRST").Delete On Error GoTo 0 Set PickFirstSSet = ThisDrawing.PickfirstSelectionSet End Function ' ';;;下面是运行该VBA的LSP ';;; Path of PickFirstSelectSet.dvb is supposed as "...\\AutoCAD\\" ';;; '(defun c:ccVLA () ' (princ) ' (setq envcmd (getvar "CMDECHO")) ' (setvar "CMDECHO" 0) ' (vl-load-com) ' (vla-runmacro (vlax-get-acad-object) (strcat (vla-get-path (vlax-get-acad-object)) "\\PFSSet.dvb!PFSS")) ' (setvar "CMDECHO" envcmd) ' (princ) ')
|