How to read last (let's say) 10 lines in command line using vb net

How to read last (let's say) 10 lines in command line using vb net

Anonymous
Not applicable
2,276 Views
9 Replies
Message 1 of 10

How to read last (let's say) 10 lines in command line using vb net

Anonymous
Not applicable

Hello there. I know How to write to  command line in Autocad using  vb net.

for example following command write to command line :

 

DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbNewLine &

 

"Hello World!" & vbNewLine)

 

 

Now my Question is ,how I can read last 10 lines in command line and put them in a variable for later use?

 

Thanks for any suggestion.

 

0 Likes
2,277 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Are you wanting to prompt for the 10 lines?

0 Likes
Message 3 of 10

kerry_w_brown
Advisor
Advisor

 

I don't have time to play, but have a look at this

 

public static List<string> GetLastCommandLines(int lastLines, bool ignoreNull);
Declaring Type:Autodesk.AutoCAD.Internal.Utils
Assembly:acmgd, Version=18.1.0.0

// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 4 of 10

Anonymous
Not applicable

No Jeffrey , I want the program read the content of command line , what ever it was there before.

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

It looks like Mr. Brown answered your question in the post above.

0 Likes
Message 6 of 10

Anonymous
Not applicable

Kerry and Jeffrey,

Thanks, Very much, After 3 hours try and error I made that works. I am not a professiional programmer and not familiar with terminology. I had to see an actual example but the keywork Kerry provided was helpful and that was exactly what I wanted. Again thank you gentlemen . You helped me to keep my new job.

Regards,

 

0 Likes
Message 7 of 10

Anonymous
Not applicable

No need to thank me I did not do anything.

But if your job was on the line all you would have to do is post some code or show that you are trying and ask for a code example and I would have tried or someone else would have helped you out.

0 Likes
Message 8 of 10

kerry_w_brown
Advisor
Advisor

 

Great to see that your issue is resolved 🙂

Could you post your sample code so that others may benefit.

Regards

..


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 9 of 10

Anonymous
Not applicable
Here is working code . I simplified it.
 Sub Test()
        Dim commandline As System.Collections.Generic.List(Of String)
        Dim I As Integer
        Dim TempT As String
        ' Get most recent last 10 lines of command lines
        commandline = Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines(10, True)
        For I = 0 To commandline.Count - 1
            TempT = Trim(commandline.Item(I))
            MsgBox(TempT)
        Next
    End Sub

 

 

0 Likes
Message 10 of 10

CADbloke
Advocate
Advocate

or you could just read the logfile - find it with logfilename:  https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/3PP-A...

- - - - - - -
working on all sorts of things including www.tvCAD.tv & www.CADreplace.com
0 Likes