jkbanana 发表于 2007-11-16 13:36:00

PickfirstSelectionSet选择集的问题?

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

王咣生 发表于 2007-11-16 21:40:00

<p>Not (ssetObj Is Nothing) </p><p>不知道用的对不对?</p><p>是不是要通过ssetObj.Count来限定一下?</p>

jkbanana 发表于 2007-11-19 12:27:00

<p>第二次调用时,错误发生在函数PickFirstSSet() 的</p><p>&nbsp;&nbsp;&nbsp;&nbsp; Set PickFirstSSet = ThisDrawing.PickfirstSelectionSet<br/>语句。</p><p>该函数引用站内mccad发的帖子</p>
页: [1]
查看完整版本: PickfirstSelectionSet选择集的问题?