Jump to content

Open Dwg with a lisp


BrianTFC

Recommended Posts

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

Link to comment
Share on other sites

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))
 )
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

...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 :thumbsup:

 

...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. :beer:

 

Cheers

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...