Hi all,
does anyone know a method how a ulp can detect if there are unsaved
changes in a board, schematic or library?
--
Lorenz
Hi all,
does anyone know a method how a ulp can detect if there are unsaved
changes in a board, schematic or library?
--
Lorenz
I don't think there is any status information that can be obtained from ULP directly, I just went through the docs again and couldn't see anything. You could probably do it by having a ULP that initially exits with the WRITE command to save the current design to a temporary location and calls back to itself (or a second ULP) and then calls system() to run a diff command to determine if there are any changes between the two. It's a not particularly clean way to do things but it would probably work. Maybe somebody else can think of something cleaner.
Best Regards,
Rachael
Rachel is correct.
I have been asking for a "dirty" flag in both the board and schematic
classes for years.
If you're trying to make sure a file is saved, the best way to do it is
to test for an argument to your ULP. The absence of the argument
indicates that the file has NOT been saved. The ULP can then save the
file and re-execute itself with the argument appended. The second pass
through the ULP would indicate that the file has already been saved and
is thus not dirty.
Below is an excerpt from a ULP that does exactly that:
//
// A separate instance of Eagle will be invoked from the command line
// to produce gerber files. As such, it does not have access to objects
// in this process's memory space and can only read from the disk.
//
// Therefore, it is imperative to make sure this board is saved
before allowing
// this program to continue.
//
// Make sure the board is saved after any drill changes
//
string file;
if(argv[1] != "saved") {
board(B) {
file = B.name;
}
// For the unix/linux/mac world, test will work.
// For Windoze, something else will have to figure out if
// the file is writable.
if (system("test -w " + file) == 0) {
// By here, the file is writable. Save it and restart this
script.
exit("write;\nrun camprep saved;\n");
} else {
if (dlgMessageBox("!
" + file + "
"The board file is not writable."
+ "
CAM files will be built from last saved version.",
"&Continue", "&Abort") != 0) {
exit(0);
}
}
}
...
HTH,
- Chuck
On 09/12/2016 07:42 AM, rachaelp wrote:
I don't think there is any status information that can be returned from ULP directly, I just went through the docs again and couldn't see anything. You could probably do it by having a ULP that initially exits with the WRITE command to save the current design to a temporary location and calls back to itself (or a second ULP) and then calls system() to run a diff command to determine if there are any changes between the two. It's a not particularly clean way to do things but it would probably work. Maybe somebody else can think of something cleaner.
Best Regards,
Rachael
--
To view any images and attachments in this post, visit:
| 1805.att1.html.zip |
Rachel is correct.
I have been asking for a "dirty" flag in both the board and schematic
classes for years.
If you're trying to make sure a file is saved, the best way to do it is
to test for an argument to your ULP. The absence of the argument
indicates that the file has NOT been saved. The ULP can then save the
file and re-execute itself with the argument appended. The second pass
through the ULP would indicate that the file has already been saved and
is thus not dirty.
Below is an excerpt from a ULP that does exactly that:
//
// A separate instance of Eagle will be invoked from the command line
// to produce gerber files. As such, it does not have access to objects
// in this process's memory space and can only read from the disk.
//
// Therefore, it is imperative to make sure this board is saved
before allowing
// this program to continue.
//
// Make sure the board is saved after any drill changes
//
string file;
if(argv[1] != "saved") {
board(B) {
file = B.name;
}
// For the unix/linux/mac world, test will work.
// For Windoze, something else will have to figure out if
// the file is writable.
if (system("test -w " + file) == 0) {
// By here, the file is writable. Save it and restart this
script.
exit("write;\nrun camprep saved;\n");
} else {
if (dlgMessageBox("!
" + file + "
"The board file is not writable."
+ "
CAM files will be built from last saved version.",
"&Continue", "&Abort") != 0) {
exit(0);
}
}
}
...
HTH,
- Chuck
On 09/12/2016 07:42 AM, rachaelp wrote:
I don't think there is any status information that can be returned from ULP directly, I just went through the docs again and couldn't see anything. You could probably do it by having a ULP that initially exits with the WRITE command to save the current design to a temporary location and calls back to itself (or a second ULP) and then calls system() to run a diff command to determine if there are any changes between the two. It's a not particularly clean way to do things but it would probably work. Maybe somebody else can think of something cleaner.
Best Regards,
Rachael
--
To view any images and attachments in this post, visit:
| 1805.att1.html.zip |