Jump to content
BrianTFC

Open Dwg with a lisp

Recommended Posts

BrianTFC

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

Share this post


Link to post
Share on other sites
BlackBox

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

Share this post


Link to post
Share on other sites
Bill Tillman

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.

Share this post


Link to post
Share on other sites
BlackBox

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

Share this post


Link to post
Share on other sites
BrianTFC

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

Share this post


Link to post
Share on other sites
BrianTFC

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

Share this post


Link to post
Share on other sites
BlackBox
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)?

Share this post


Link to post
Share on other sites
BrianTFC

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

Share this post


Link to post
Share on other sites
BrianTFC

BlackBox,

 

do you need more information to make this work?

 

thx

Brian

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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