BrianTFC Posted July 10, 2013 Posted July 10, 2013 All, I found this Lisp that Renderman wrote; it works great. I was wondering what do i need to do to it so it continues to open the file even if part of the filename changes ie; the date without changing the code everytime it's updated NEW JOB TEMPLATE-7-8-13 - SMALL.dwg (defun c:OpenMyDwg ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((:vlax-false))))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "F:\\DRAWINGS\\ARCHITECTURAL DETAILS\\NEW JOB\\NEW JOB TEMPLATE-7-8-13 - SMALL.dwg" T) (princ)) Thanks, Brian Quote
BlackBox Posted July 10, 2013 Posted July 10, 2013 I found this Lisp that Renderman wrote; it works great. I was wondering what do i need to do to it so it continues to open the file even if part of the filename changes ie; the date without changing the code everytime it's updated NEW JOB TEMPLATE-7-8-13 - SMALL.dwg I haven't seen RenderMan in some time, but if I might ask about the date situation... Are you changing date daily, looking to enable a selection by dialog, or just always wanting to open the latest and greatest (regardless of the actual date itself)? Also, I don't think he'll mind if I offer a slight adaptation to his code: (vl-load-com) (defun _OpenDwg (dwg readOnly / doc) ;; BlackBox... Inspired by RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) ;; Return: T, if successful; otherwise nil. (and (not (vl-catch-all-error-p (setq doc (vl-catch-all-apply 'vla-open (list (vla-get-documents (vlax-get-acad-object)) dwg (if readOnly :vlax-true :vlax-false ) ) ) ) ) ) (not (vla-activate doc)) ) ) Quote
Bill Tillman Posted July 10, 2013 Posted July 10, 2013 Just use this on the command line: (_OpenDwg "F:\\any_path_name_you_want\\any_filename_you_want.dwg" T) You could also use code to get input from the user for which file they want to open....this seems kind of the hard way of doing it when most of the time the recent files are still in the File pull down menu...and there are already file dialog boxes built into AutoCAD for opening files. However, we all have our own needs and reasons for doing things a certain way. Quote
BlackBox Posted July 10, 2013 Posted July 10, 2013 ...this seems kind of the hard way of doing it when most of the time the recent files are still in the File pull down menu. ... Not so if one uses SSM for all projects, as the all the recent files are .DST ...and there are already file dialog boxes built into AutoCAD for opening files. However, we all have our own needs and reasons for doing things a certain way. Agreed, but rarely do these dialog automatically go to a project-specific, relative folder for one to select from (without customization)... Hence my request for additional information above. Cheers Quote
BrianTFC Posted July 11, 2013 Author Posted July 11, 2013 I just want to open the latest and greatest (regardless of the actual date itself)? the only thing that get updated is the date 7-8-13. Thanks, Brian Quote
BrianTFC Posted July 22, 2013 Author Posted July 22, 2013 Blackbox, is it possible to make this happen? I just want to open the latest and greatest (regardless of the actual date itself)? the only thing that get updated is the date 7-8-13. Thanks, Brian Quote
BlackBox Posted July 22, 2013 Posted July 22, 2013 Blackbox, is it possible to make this happen? I just want to open the latest and greatest (regardless of the actual date itself)? the only thing that get updated is the date 7-8-13. I still don't have enough information, really... Okay, so the date within the filename is what changes; is it always today's date? Do you want to be prompted to enter the date? Is the date always in that format (i.e., MM-DD-YY)? Quote
BrianTFC Posted July 22, 2013 Author Posted July 22, 2013 Question 1 = no it's not always today's date it whenever it gets updated Question 2 = If i don't have to, becuase then i would have to look for it everytime. Question 3 = yes this is the format I hope this helps. thx Quote
BrianTFC Posted July 28, 2013 Author Posted July 28, 2013 BlackBox, do you need more information to make this work? thx Brian 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.