shakuhachi Posted April 22, 2011 Posted April 22, 2011 I've search every where but couldn't find a lisp routine so I might as well ask. Let say I have a file named "Mech-Poject1" , "Project1-Mech-Job#" , "Job#-Mech". We don't have a standard on naming files so i'm having problem stripping out the file name and look for the word "MECH" on it. With a lisp routine how can I know if the file name of my current drawing have the word "MECH" on it. I'm planning to modify my "qsave and save" command to do an extra command/lisp routine if I'm in one of those drawings. To make it more clear, if I'm working on my mechanical drawing with the string "MECH" on the file name, it will run a routine that will create a backup file on a super-seeded folder with the date on it and then do a save command as well. If I open a drawing named "Elec-Project" and hit save. It will just save the drawing since I don't have the string "mech" on the file name. Any help is much appreciated. Quote
LibertyOne Posted April 22, 2011 Posted April 22, 2011 You would have to call up the system variable DWGNAME (getvar "DWGNAME") the result is a string which you would have to then filter with your string "mech" Quote
shakuhachi Posted April 22, 2011 Author Posted April 22, 2011 I know how to get the file name with dwgname or vl-filename-base. I just don't know how to check if the string "mech" is on the filename since it can be in the 1st, middle, or last string on the file name. I don't know how to start my code. If it just the first 4 string or the last 4 string on the filename, that I can do but to search on the entire filename, that I can't do. Quote
BlackBox Posted April 22, 2011 Posted April 22, 2011 Instead of using substr, try this: (vl-load-com) (vl-string-search "MECH" (strcase (getvar 'dwgname))) This will find the string, no matter the position (i.e., beginning, middle, end, etc.). Hope this helps! Quote
shakuhachi Posted April 22, 2011 Author Posted April 22, 2011 Thanks LibertyOne and RenderMan. That's the one that I been looking for. Been thinking of a complicated code but a simple vlisp function do the job pretty well. I can sleep well for now. Instead of using substr, try this: (vl-load-com) (vl-string-search "MECH" (strcase (getvar 'dwgname))) This will find the string, no matter the position (i.e., beginning, middle, end, etc.). Hope this helps! Quote
BlackBox Posted April 22, 2011 Posted April 22, 2011 Sometimes it's the little things we overlook... Glad to help. Quote
alanjt Posted April 22, 2011 Posted April 22, 2011 You could also use wcmatch eg. (wcmatch (strcase (getvar 'dwgname) "*MECH*") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.