TheSwamp

Code Red => VB(A) => Topic started by: jjs on December 06, 2005, 06:26:02 PM

Title: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: jjs on December 06, 2005, 06:26:02 PM
-2147467259 Method 'Count' of object 'IAcadSelectionSet' failed
This bug in AutoCAD causes this
and similar errors with AcadSelectionSet when
the code is run immediately after issuing the
OPEN command and then cancelling it.

Anyone have a work around?

Code: [Select]
Public Sub ConvertText2Mtext(Optional intUsePrevious As Integer)
Dim ssText As AcadSelectionSet
Dim ssPrev As AcadSelectionSet
Dim objAcTxt As Object
Dim objAcTxt2(0 To 0) As Object
Dim acText As AcadText ' i added
Dim acMtext As AcadMText ' i added

On Error GoTo Err_Control

myZ = 0
intActiveSpace = ThisDrawing.ActiveSpace

'///Since this set is temporary, switched to PF
Set ssText = ThisDrawing.PickfirstSelectionSet

If intUsePrevious = 1 Then
'Set ssPrev = ThisDrawing.SelectionSets.Add("TEST_SELECTIONSET")
   
    Set ssPrev = ThisDrawing.PickfirstSelectionSet
      ssPrev.Select acSelectionSetPrevious

  For Each objAcTxt2(0) In ssPrev 'CRASHES HERE
      If TypeOf objAcTxt2(0) Is AcadText Then
          ssText.AddItems objAcTxt2
      End If
  Next


Else

if you draw something in a blank drawing. Then type OPEN at the command prompt and then close the OPEN FILE DIALOG without picking a drawing. Then run a selection set routine, it crashes. YOu have to restart autocad to get the selection sets working again. I know, don't cancel the open dialog. But my users did not like that answer. ANybody know a fix?
Title: Re: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: Keith™ on December 06, 2005, 07:36:37 PM
Perhaps it is an error generated when "ThisDrawing" is not actually the current drawing ... it could be a problem with AuoCAD itself .. as I have had no problem with this issue myself ... I will attempt to duplicate your problem in the morning
Title: Re: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: Jeff_M on December 06, 2005, 07:55:23 PM
jjs,
I just tried to duplicate this and had no success. I'm testing it with R2002 and I did have to make some changes to your code for it to be tested.

I will say that I've had users report to me similar Error messages, all were using R2004+, and I found that by going back to a named SS in place of the PickFirstSS it solved the problem.
Title: Re: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: Chuck Gabriel on December 06, 2005, 09:04:05 PM
jjs,
I just tried to duplicate this and had no success. I'm testing it with R2002 and I did have to make some changes to your code for it to be tested.

I will say that I've had users report to me similar Error messages, all were using R2004+, and I found that by going back to a named SS in place of the PickFirstSS it solved the problem.


Ditto.
Title: Re: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: jjs on December 07, 2005, 10:53:21 AM
I am using R2004. I will have to look up the difference between pickfirst and named.
Title: Re: Method 'Count' of object 'IAcadSelectionSet' failed
Post by: jjs on December 09, 2005, 10:54:06 AM
named selectionsets fixed it. thanks