Catching command window output with .NET-api

Catching command window output with .NET-api

ottosson_mathias
Advocate Advocate
1,884 Views
7 Replies
Message 1 of 8

Catching command window output with .NET-api

ottosson_mathias
Advocate
Advocate

Are there any way of catching the command window history/text in AutoCAD using the .NET API? I would like to be able to save it for debugging purposes.

0 Likes
Accepted solutions (1)
1,885 Views
7 Replies
Replies (7)
Message 2 of 8

_gile
Consultant
Consultant

Hi,

 

You can play with the LOGFILEMODE and LOGFILENAME system variables.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 8

ottosson_mathias
Advocate
Advocate

Thanks. (Just fyi, both links goes to LOGFILEMODE)

 

So no api-access? I would like to analyze it in real-time in my add-in, and reading from a file feels a bit awkward.

0 Likes
Message 4 of 8

Alexander.Rivilis
Mentor
Mentor

@ottosson_mathias wrote:

Are there any way of catching the command window history/text in AutoCAD using the .NET API? I would like to be able to save it for debugging purposes.


It is possible with ObjectARX: https://adndevblog.typepad.com/autocad/2012/09/trapping-the-output-from-the-autocad-text-screen-comm...

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 5 of 8

jabowabo
Mentor
Mentor
Accepted solution

Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines(int, bool)

 

Example:

int lineCount = 20;
bool ignoreNull = true;
string cmds = "";
List<string> cmdLineList = Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines(lineCount, ignoreNull);
cmdLineList.Reverse();
foreach (string str in cmdLineList)
{
  cmds += str + Environment.NewLine;
}
MessageBox.Show(cmds);
Message 6 of 8

ottosson_mathias
Advocate
Advocate

Thanks @jabowabo, I'll try it in the coming days.

 

Bonus question: Is it possible to get all the lines, not just a fixed amount?

0 Likes
Message 7 of 8

jabowabo
Mentor
Mentor

The method takes an int parameter so you'll have to supply something. You could just give it a very high number like 999999 (unless you think you'll have more than a million lines 😜)

Message 8 of 8

ottosson_mathias
Advocate
Advocate

This works.

Thanks a lot!

0 Likes