How to edit g code files
古いコメントを表示
Hi, I'm searching for a way to edit g code files in matlab, what type of script can I use?
4 件のコメント
dpb
2022 年 8 月 15 日
G code files are just text so you can manually open them in the editor just like m files. Of course, there's no context-sensitve help, auto-complete, etc., etc., ...
What do you mean to try to do with MATLAB and the files -- make automatic code changes of parameters like say a spindle speed or somesuch?
If so, the only tools MATLAB has to offer for the purpose are the basic string handling functions -- one might find the new(ish) pattern matching function that is similar to writing regular expressions (regexp) useful unless you're already familiar with its syntax.
It's been nearly 40 years since I've done anything in the area so I've no idea what toolsets are out there now -- back then one was mostly tied into the vendor's proprietary toolset; it's undolubtedly possilbe now to find generic tools and I'm sure there must be handy generic editors/programming environments. Whether there might be some developed for/in MATLAB ...
Well, there's at least one FEX submission <fileexchange/67767-g-code-reader>
Walter Roberson
2022 年 8 月 15 日
Please read https://www.mathworks.com/matlabcentral/answers/1779410-append-data-to-the-already-existed-txt-file-horizontally#answer_1026560 which discusses what has to be done to edit text files.
Federico Paolucci
2022 年 8 月 16 日
Walter Roberson
2022 年 8 月 16 日
To summarize: unless you have fixed length records and never need to insert or delete records, then you should probably be reading from one file, modifying the in-memory copy, and writing the modified version to a new file.
Depending on what changes have to be made, sometimes there are efficient ways to make some kinds of changes. For example it might be efficient to change all occurances of 'G2' to 'G3,0' in-memory.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!