Extended macro syntax

To make macro support in kisslicer easier, GPX macro syntax can either
be ;@macro ... or (@macro …)
master
WHPThomas 2013-09-26 16:24:16 +10:00
parent fef289d700
commit e28aad0282
3 changed files with 24 additions and 8 deletions

27
gpx.c
View File

@ -2610,16 +2610,30 @@ int main(int argc, char * argv[])
// null terminate
if(*s) *s++ = 0;
parse_macro(macro, normalize_comment(s));
*p = 0;
break;
}
}
else {
// Comment
command.comment = normalize_comment(p + 1);
command.flag |= COMMENT_IS_SET;
}
// Comment
command.comment = normalize_comment(p + 1);
command.flag |= COMMENT_IS_SET;
*p = 0;
break;
}
else if(*p == '(') {
if(*(p + 1) == '@') {
char *s = p + 2;
if(isalpha(*s)) {
char *macro = s;
// skip any no space characters
while(*s && !isspace(*s)) s++;
// null terminate
if(*s) *s++ = 0;
parse_macro(macro, normalize_comment(s));
*p = 0;
break;
}
}
// Comment
char *s = strchr(p + 1, '(');
char *e = strchr(p + 1, ')');
@ -2638,7 +2652,8 @@ int main(int argc, char * argv[])
fprintf(stderr, "(line %u) Syntax warning: comment is missing closing ')'" EOL, lineNumber);
command.comment = normalize_comment(p + 1);
command.flag |= COMMENT_IS_SET;
*p = 0;
*p = 0;
break;
}
}
else if(*p == '*') {

3
gpx.py
View File

@ -24,7 +24,8 @@ x3gFile = profile.getPreference('lastFile')
x3gFile = x3gFile[0:x3gFile.rfind('.')] + '.x3g'
commandList = [getGpxAppName(), '-p', '-r']
commandList += ['-m', machineType]
if machineType is not None and machineType != '':
commandList += ['-m', machineType]
commandList += [filename, x3gFile]
call(commandList)

View File

@ -26,7 +26,6 @@ G4 P3500 (pre-prime extruder)
G1 X140 Y70 Z0.2 F1100 (do a slow wipe...)
G1 X140 Y70 Z0.5 F1100 (...and lift)
M108 R0.0 (stop extruder)
;@body (notify GPX body has started)
(**** PAUSE @ ZPOS MACROS ****)
;@slicer 1.70mm
;@filament white 1.75mm 230c #FFFFFF (white filament)
@ -35,6 +34,7 @@ M108 R0.0 (stop extruder)
;@start white
;@pause 6.0 blue
;@pause 3.0 red
;@body (notify GPX body has started)
(**** end of start.gcode ****)
G92 E0
(**** Select Extruder.gcode ****)