.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CommandMethod executes command only once ?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
302 Views, 2 Replies

CommandMethod executes command only once ?

I am having a very interesting problem with my code. When I run my code the first time CommandMethod works and executes without any problems, When I try to run it again I get : Unknown command. I have to reopen AutoCAD in order to run the command again.

 

Has anyone experience this problem before.

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

I just ran some test and I got strange but consistent results. When I run the code on AutoCAD 2008 the command run only once, but when I run it on AutoCAD 2010 it works without any problems.

 

It is really strange that the same code runs in 2010 without any problems and in 2008 it is only willing to run once.

Message 3 of 3
Anonymous
in reply to: Anonymous

Hi everyone, I was able to narrow the problem to ‘System.IO.StreamReader

 

At the start of my code I read a large data file (9000 lines) in with this code:

 

 

Public Class Test
    <CommandMethod("ttt", CommandFlags.Modal)> _
    Public Sub Test()

        Dim objReader As New System.IO.StreamReader("C:\Test.txt")

        Do
            sLine = objReader.ReadLine()
            If Not sLine Is Nothing Then
                Debug.Print(sLine)
            End If
        Loop Until sLine Is Nothing

        objReader.Close()
    End Sub
End Class

 

After reading in the file in, when I try to read the file again I get an ‘Unknown command’. I wonder if the problem is with the buffer . . . . . .

 

Or perhaps there is a workaround this issue.

 

Thank you,

 

-J

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost