brandalf_the_semiGray Posted March 5, 2020 Posted March 5, 2020 In C and C++ we have the ability to customize the text width of a block of text so that things will be printed nicely to your output stream in the same "column" if you will. Is there anything like this in autolisp? As you can see in the clip below, the text is not aligned very nicely. I want to know whether there's a way to align "columns" easily, or if i have to get creative with my print logic. Thanks in advance, Brandon Quote
fuccaro Posted March 5, 2020 Posted March 5, 2020 For just few results, the text screen is fine. But it's not easy to keep large amount of data well formatted. Have you consider to write from Lisp in Excel? Or even simpler, write in a CSV file (just text, using comma as separator) and open it in Excel. Quote
pkenewell Posted March 5, 2020 Posted March 5, 2020 (edited) When you string together the information, you could use the "\t" code to insert a Tab between columns. To made the gap wider, add multiple Tabs like "\t\t\t". EDIT: Well - never-mind. It dosen't work well with the command line. I tried (princ "TEST1\tTEST2\tTEST3\tTEST4\nVAl1\tVAL2\tVAL3\tVAL4\n") and it still does not align for crap. You would be better off making a padding routine to added spaces based on the longest text in the list - and that might still not get things aligned perfectly. Edited March 5, 2020 by pkenewell Quote
brandalf_the_semiGray Posted March 5, 2020 Author Posted March 5, 2020 I'd like to keep everything in autocad for this application because the function needs to be run iteratively. basically based of whether the results meet your expectation, you can undo everything, or save the results. But I want to be able to do this without having to flip between another program. I'm thinking a padding routine will be my best bet at this point. Quote
BIGAL Posted March 5, 2020 Posted March 5, 2020 (edited) The way text is displayed is controlled by the font and I have no idea how you would change it may be a windows thing choosing a font. More than likely a regedit.One way around is to write mtext and use tabs as mentioned very little testing seemed to work. Have a look at Monotxt.shx this is fixed spacing, should be a TTF that is fixed spacing. You could write a file and pop open using notepad with tabs, but you need to close. Did a quick goggle and you can change the default font of windows so that may be a starting point. Edited March 5, 2020 by BIGAL Quote
brandalf_the_semiGray Posted March 5, 2020 Author Posted March 5, 2020 12 minutes ago, BIGAL said: The way text is displayed is controlled by the font and I have no idea how you would change it may be a windows thing choosing a font. More than likely a regedit.One way around is to write mtext and use tabs as mentioned very little testing seemed to work. Have a look at Monotxt.shx this is fixed spacing, should be a TTF that is fixed spacing. You could write a file and pop open using notepad with tabs, but you need to close. Did a quick goggle and you can change the default font of windows so that may be a starting point. I just want the data shown in the command line to be formatted nicely when printed. Text font and size is fine as is. Quote
BIGAL Posted March 5, 2020 Posted March 5, 2020 I don't think you understand what I posted when working with multi line text the characters are not equal spaced. Look at monotxt.shx for equal spacing. You need to change the font to a equal spaced character font to do what you want or try using tabs. Quote
brandalf_the_semiGray Posted March 6, 2020 Author Posted March 6, 2020 14 hours ago, BIGAL said: I don't think you understand what I posted when working with multi line text the characters are not equal spaced. Look at monotxt.shx for equal spacing. You need to change the font to a equal spaced character font to do what you want or try using tabs. OH. Yes, on that front I see what you're saying. I don't see changing the default text on windows as feasible for a solution that I want to roll out to the rest of the computers at my work however. I've also tried tabs, but I get strange results. I think the best bet here is to scan the list for the longest entry, and then pad everything to that size. Either that or make an assumption about the maximum length of any given output and then pad everything to my assumed size. I like the flexibility and potential for function reuse that a dynamic pad size provides. Quote
pkenewell Posted March 6, 2020 Posted March 6, 2020 @brandalf_the_semiGray NOTE: You CAN change the command line font in the AutoCAD options to a Monospaced font. Quote
BIGAL Posted March 7, 2020 Posted March 7, 2020 Sometimes it is just sitting there. Try a MONO...…. font and see if it works. Quote
brandalf_the_semiGray Posted March 7, 2020 Author Posted March 7, 2020 (edited) I got it sorted out by padding the output with spaces. Thanks everyone. I think this is an ideal situation because I don't have to change any system settings to use my routine on everyone's computer. I want the interface to be simple and zero setup aside from loading the lisp. Padding isn't 100% perfect, but its organized and readable enough to suffice. Again, I appreciate all the ideas and pointers. Part of me was hoping there were stream operators like in C and C++ that make it easy to format command line output. That might be a fun project to start in on... write a library of functions for command line output formatting. I'll bet the text font even has a system variable somewhere that can be changed via code. I don't suppose anyone knows of any libraries for creating charts and histograms in cad itself? Edited March 7, 2020 by brandalf_the_semiGray Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.