Author Topic: Method 'Count' of object 'IAcadSelectionSet' failed  (Read 5175 times)

0 Members and 1 Guest are viewing this topic.

jjs

  • Guest
Method 'Count' of object 'IAcadSelectionSet' failed
« 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?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Method 'Count' of object 'IAcadSelectionSet' failed
« Reply #1 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Method 'Count' of object 'IAcadSelectionSet' failed
« Reply #2 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.

Chuck Gabriel

  • Guest
Re: Method 'Count' of object 'IAcadSelectionSet' failed
« Reply #3 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.

jjs

  • Guest
Re: Method 'Count' of object 'IAcadSelectionSet' failed
« Reply #4 on: December 07, 2005, 10:53:21 AM »
I am using R2004. I will have to look up the difference between pickfirst and named.

jjs

  • Guest
Re: Method 'Count' of object 'IAcadSelectionSet' failed
« Reply #5 on: December 09, 2005, 10:54:06 AM »
named selectionsets fixed it. thanks