Great work! I was thinking along the same lines, just didn't have the time. BTW, my idea was to save a list of drawings to be opened into a registry folder. The loader would then check if the current DWG is one of them in that folder, if so - then run the script/lsp/etc. and delete that value out of the folder, then close the DWG and open the 1st one in the reg folder.
Was there a reason you didn't go that route and rather used a marker Batchworx.DWG file?
Just a thought, could you put the countdown variable into the blackboard namespace?
(vlr-docmanager-reactor nil '((:vlr-documentBecameCurrent . batchworx_check_counter)))
(defun batchworx_check_counter( / )
(if (= (vl-bb-ref 'batch_counter) 1) (progn (batchworx_cleanup)(vl-bb-set 'batch_counter nil))
)
;; Add the start up
(defun S::STARTUP (/)
;;; ------------ ECHO TO THE COMMAND LINE
(princ "\n Begining Batch Process \n")
;; <LOAD DEPENDENT LISPS HERE>
;; <ADD CONTENT HERE>
(vl-cmdf "union" "all" "")
(vl-cmdf "-view" "o" "front")
(vl-cmdf "zoom" "extents")
(vl-cmdf "zoom" "scale" "0.9x")
;; Save the file - if needed
(vl-cmdf "QSAVE")
;; Set the clean up program (remove semi-colons)
;;(if (= (vl-registry-read BatchMasterKey "Clean") "nil")
;; (vl-registry-write BatchMasterKey "Clean" "<FILENAME>")
;;)
;; Close the drawing
(vl-cmdf "CLOSE")
)s
It worked really well. The resulting files were great.
Try this one and see if this prevents multiple sessions.
Try this one and see if this prevents multiple sessions.
Tim,
I was trying out your code in Bricscad. Had do some obvious tweaks of course, but then ran into similar problems as matthewj. The comments below are therefore based on limited tests and I was not using your latest code.
1.
You should consider this scenario: The user selects some drawings for processing and then decides to switch to a different folder. But instead of selecting a new folder the user changes his mind and cancels the folder dialog. Your main dialog now reports: "NO DIRECTORY SET", but the left list_box is not cleared. In fact you can still select items from the list resulting in "nilDrawingName.dwg" entries in the right list_box.
I found this issue an I think that I have fixed it to retain the current directory is the user cancels.
2.
The folder dialog you are using has certain limitations. If you start it in a specified folder the browsing is restricted to that folder and its subfolders. You usually don't want that. On the other hand, always having to start browsing from the "My documents" folder is inefficient. Not many companies use this folder or even the C: drive for their project folders. A solution can be to add a main-project-folder option to your config settings. If such a folder is set the folder dialog can start from that folder saving the user 4-5 clicks every time he uses the program.
There is not much out there for directory selection unless you roll your own. Unfortunately this is what we have to work with.
3.
The right list_box is sorted alphabetically the left list_box is not.
Fixed
4.
It would be nice if the dwgs that have already been selected are marked in the left list_box. For example by adding some spaces before the item string.
I am looking at the code, I am thinking of removing the drawings from the list as they are added to the batch list, and vice-versa.
5.
Since the dwgs in the right list_box can come from different folders it makes sense to display the full path for each dwg. That would perhaps mean having to do away with the symmetry of the dialog.
How about adding a description tile below to show the full path of a selected file? If I enable the full path in the listbox the listboxes could get very wide.
6.
"Select all" and "Clear all" buttons would be nice.
Good Idea
7.
The bottom button row of your main dialog now has this order:
"Process" "Cancel" "About" *space* "Config"
I would use this order:
"About" "Config" *space* "Process" "Cancel"
That order is more in keeping with the general '"flow" of the dialog.
How so?
8.
The separators in your dialogs sometimes have -2 as their background color. I think this should always be -15.
Good catch, fixed. That's what I get for coping code from other applications.
9.
You use a lot of text_part tiles instead of normal text tiles. I don't understand why.
I have found that text_part is a bit more flexible during design. It allows text to be moved around <tabbed> by adding other parts to it. also there are no margins on text_parts so it seems easier to control the space around them.
HTH.
Roy.
5.
Since the dwgs in the right list_box can come from different folders it makes sense to display the full path for each dwg. That would perhaps mean having to do away with the symmetry of the dialog.
How about adding a description tile below to show the full path of a selected file? If I enable the full path in the listbox the listboxes could get very wide.
That is a good alternative. Most companies would use some unique project number as part of the dwg name anyway.
7.
The bottom button row of your main dialog now has this order:
"Process" "Cancel" "About" *space* "Config"
I would use this order:
"About" "Config" *space* "Process" "Cancel"
That order is more in keeping with the general '"flow" of the dialog.
How so?
See below.
9.
You use a lot of text_part tiles instead of normal text tiles. I don't understand why.
I have found that text_part is a bit more flexible during design. It allows text to be moved around <tabbed> by adding other parts to it. also there are no margins on text_parts so it seems easier to control the space around them.
Bricscad does not correctly display these texts with "\t". One of my tweaks was to replace "\t" with " ".
All things being equal, users first look in the upper left corner of a window, scan across the page, and end their scan in the lower right corner. They tend to ignore the lower left corner.
(vl-string-trim ";| \t" str)
Tim, I have just tried out the latest version of your lisp (from post #19).
Here are some additional comments:
10. (The numbering continues where my previous post has left off)
The "spawning" of multiple CAD sessions now only occurs if there are multiple sessions open when the Batch command is started.
Still looking into this.. I have to grab ALL open session then alert the user is there are more than 1
11.
If a single session is active when the routine is run, the program works OK. But for every drawing that is opened by the process I have to click the OK button in a "Processing in progress... Please be patient" alert dialog. So the process can't be left unattended. This maybe a Bricscad thing though.
This is because of the .batch file. Look in there and remove the alert (or comment it out). It was only for demo purposes
12.
Another scenario to consider: The batch process fails for whatever reason. The user gets called away, forgets what he has been doing, and start a CAD session by double clicking on a dwg file. This dwg will now be processed by the batch routine, saved and closed. And if the process runs successfully the user cannot open any other dwg to continue working, because that dwg would also be processed. Using a script to open the drawings and start the .batch file would be safer. In Bricscad this is also faster and there are no alert dialogs. But I know your goal is not to use scripts.
Have you had this happen. If the batchworx fails then AutoCAD should crash. Thus a new drawing would open resetting batchworx.
13.
And another scenario: The user selects the calling dwg for processing...
I have added a check for this once the "process" button is selected, however it is only if it is called in that dwg. I'll have to spend some more time with that.
14.
Your Batchworx.docx is not entirely clear about the use of the Batch subfolder. After reading the text I put both .batch file examples in that folder and one of them (Batchworx.lsp) was then erased by your program.
ODD it should only delete file with a .batch ext. I will try to clear up the documentation a bit. Essentially there are 2 location (a network) (a user) both can have .batch files or you can just use 1 location (if you are standalone)
Again, HTH.
Roy.
alignment = "left";
This should be:alignment = left;
But this line can also be removed.Upon further testing, this time with the Windows Task Manager open, I find that the lisp program will ALWAYS spawn multiple CAD sessions in Bricscad. My conclusion is therefore that this approach to batch processing will not work for Bricscad.
I am looking into this a bit more, I can't seem to capture the current session and keep the dwgs in it.
In Bricscad there are two ways to run a batch process:
A.
You can use a script. This will also work in Autocad.
B.
You can use a SINGLE lisp program to handle the entire process.
In Bricscad you can:
- Start a lisp program in drawing A.
- Open drawing B.
- Perform various tasks in dwg B: execute lisp code, call commands (they will run in dwg B) etc.
- Save and close dwg B.
- Open drawing C.
- ... etc.
This is, apparently, not possible in Autocad.
Nope, other wise this would be a lot easier :roll:
Some comments (old and new):
4.
It would be nice if the dwgs that have already been selected are marked in the left list_box. For example by adding some spaces before the item string.
T:
I am looking at the code, I am thinking of removing the drawings from the list as they are added to the batch list, and vice-versa.
R:
The vice-versa part has not yet been implemented.
Yes it has, however if you try to "unload" dwg's from the right side and they are not from the "current" directory they just get dumped, not added back to the left (they don't belong there)
5.
Since the dwgs in the right list_box can come from different folders it makes sense to display the full path for each dwg. That would perhaps mean having to do away with the symmetry of the dialog.
T:
How about adding a description tile below to show the full path of a selected file? If I enable the full path in the listbox the listboxes could get very wide.
R:
That is a good alternative. Most companies would use some unique project number as part of the dwg name anyway.
R:
Very nice work on that one. You are even handling multiple selections!
16.
You use acet-* functions without checking if they can be used. Not everybody wil have the Express Tools installed.
I noticed this yesterday when I was going through the code, this was from my StdLib which does the checking, I'll be adding the check to this also.
17.
Your dcl somewhere has:Code: [Select]alignment = "left";
This should be:Code: [Select]alignment = left;
But this line can also be removed.
Fixed
18.
The arrow buttons between the list_boxes are left aligned.
Yeah, I haven't cleaned up the dialog code yet. I will add this to the todo list.
(if (equal (strcat (vl-filename-directory SelDwg) "\\") BatchDirectory)
Line 464:(if (equal (strcat (vl-filename-directory DwgName) "\\") BatchDirectory)
4.
It would be nice if the dwgs that have already been selected are marked in the left list_box. For example by adding some spaces before the item string.
T:
I am looking at the code, I am thinking of removing the drawings from the list as they are added to the batch list, and vice-versa.
R:
The vice-versa has not yet been implemented.
T:
Yes it has, however if you try to "unload" dwg's from the right side and they are not from the "current" directory they just get dumped, not added back to the left (they don't belong there).
R:
The code is there but to get it to work 2 lines have to be changed (you are not adding "\\"):
Line 432:Code: [Select](if (equal (strcat (vl-filename-directory SelDwg) "\\") BatchDirectory)
Line 464:Code: [Select](if (equal (strcat (vl-filename-directory DwgName) "\\") BatchDirectory)
(if (equal (vl-filename-directory SelDwg) (vl-filename-directory BatchDirectory))
and
(if (equal (vl-filename-directory DwgName) (vl-filename-directory BatchDirectory))
The backslash is an escape character (http://bit.ly/18lFkEv) in AutoLISP, therefore to yield a literal backslash in a string you'll need to prefix the backslash with another backslash to mark it as a literal, i.e.:Code - Auto/Visual Lisp: [Select]
"D:\\Project\\2019\\"