identifica​tion-of-th​e-coordina​tes-of-the​-outer-edg​es-of-a-pa​rt-to-be-p​rinted-in-​3d

3 visualizaciones (últimos 30 días)
Hi, this question is similar to Identification of the coordinates of the outer edges of a part to be printed in 3d - MATLAB Answers - MATLAB Central (mathworks.com), so I'm going to written this one because the question in the link in not enough specific.
I have to write a matlab script capable of modifying a g code file: what I want to obtain is a script capable of loading the g code and dividing it into a structure with cells containing the individual commands: I want to find the strings in which the outer contour of all layers is drawn, initialized by; TYPE: WALL-OUTER, as a result of which all commands containing the token G1 at the beginning of the command are stored, followed by the X Y Z E coordinates of displacement and possibly also from F. Then, also commands with the token G0 are stored. I should therefore extract the absolute position coordinates, saved in a structure cataloged by layer to which it belongs. the points extracted from the g code must be ordered in order to have a closed path that can be represented by a polygon. the passage from one layer to the next must be indicated by the layer string, followed by the layer number starting from 0 and the height expressed in mm must be indexed in the first strings of the file through the comment; layer height, for example 0.2 mm. In the g code file there are the coordinates for each piece to be printed, they are distinguishable as the construction of the layer is preceded by the string; MESH. In particular I want to extract the coordinates for the piece "c", so it is necessary to locate the string; MESH: c.stl
  2 comentarios
Federico
Federico el 24 de Ag. de 2022
@Walter Roberson in this question I reported an accurate description of the matlab script that I need
Federico
Federico el 24 de Ag. de 2022
I started writing this
in_filename = 'file g.gcode';
out_filename =' OutputGcodeFile.txt';
str = fileread('file g.gcode');
lines = regexp(str, '\r\n|\r|\n', 'split');
IndexC = strfind(lines,';TYPE:WALL-OUTER');
look= ('G\S+\sF\S+\sX\S+\sY\S+\sE\S+');
rgx = sprintf('\\s+%c([+-]?\\d+\\.?\\d*)','XYE');
tkn = regexp(str,rgx,'tokens');
mat = str2double(vertcat(tkn{:}))

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by