Jump to content

Recommended Posts

Posted

I am trying to figure out a way to add a suffix of the current date into the file name while it places the exported file into a sub Folder "Export Current Date".

 

This is what i have came up with for the file name.

(command "-exporttoautocad" "_S" " - " (substr (rtos (getvar "CDATE") 2 0) 3) "" "")

 

This is what I am trying to incorperate into the above to make the Export Current Date Sub Folder.

Lee had this code below, I was hopeing i could it switched from copy to an export. lol

 

(defun c:sav ( / cpy sub )
   (setq sub "Superseed") ;; Subdirectory
   (cond
       (   (zerop (getvar 'dwgtitled))
           (princ "\nCurrent drawing is unsaved.")
       )
       (   (not (or (findfile (setq sub (strcat (getvar 'dwgprefix) sub))) (vl-mkdir sub)))
           (princ (strcat "\nUnable to create directory " sub))
       )
       (   (progn
               (princ "\nSaving current drawing...")
               (command "_.qsave")
               (not 
                   (vl-file-copy (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                       (setq cpy 
                           (strcat sub "\\"
                               (vl-filename-base (getvar 'dwgname)) "-"
                               ;;(menucmd "m=$(edtime,0,YYYYMODD-HHMMSS)") 
				(menucmd "m=$(edtime,0,YYYYMODD)") 
                               (vl-filename-extension (getvar 'dwgname))
                           )
                       )
                   )
               )
           )
           (princ (strcat "\nUnable to copy drawing to " cpy))
       )
       (   (princ (strcat "\nDrawing copied to " cpy)))
   )
   (princ)
)







 

Posted

whats the difference between copy and export?

 

(defun c:sav (/ cpy sub)
  (setq sub (substr (rtos (getvar "CDATE") 2 0) 3))  ;; Subdirectory
  (cond
    ((zerop (getvar 'dwgtitled))
            (princ "\nCurrent drawing is unsaved.")
    )
    ((not (or (findfile (setq sub (strcat (getvar 'dwgprefix) sub))) (vl-mkdir sub)))
          (princ (strcat "\nUnable to create directory " sub))
    )
    ((progn
        (princ "\nSaving current drawing...")
        (command "_.qsave")
        (not
          (vl-file-copy (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                        (setq cpy (strcat sub "\\" (substr (rtos (getvar "CDATE") 2 0) 3) "_" (getvar 'dwgname)))
          )
        )
      )
      (princ (strcat "\nUnable to copy drawing to " cpy))
    )
    ((princ (strcat "\nDrawing copied to " cpy)))
  )
  (princ)
)

 

Posted

I can't remember why I did it this way, but on my PDF routine  I added a date and time stamp using: 

 

(setq myfilename --filepatgh and filename-- )
(setq myfilename (strcat myfilename " [" (menucmd "M=$(edtime,$(getvar,date),DD-MO-YY)") " " (menucmd "M=$(edtime,$(getvar,date),HH-MM-SS)") "]" ))

 

Will it work using that and inserting the whole filepath and filename instead of suffixing the time and date?

  • Like 1
Posted

I had to do some research, but when you go to saveas a file out (which has AEC Objects) and explode the file etc, there still is remains of AEC Objects. The EXPORTTOAUTOCAD somehow removes everything and treats it as a new file without any remains of the AEC Objects.

 

https://www.theswamp.org/index.php?topic=54258.15

 

Quote

Even if you figure out how to expolde the aec objects your drawing will still be "infected" and that's why the exporttoautocad command creates a new drawing. There are drawing variables, dictionaries, etc... that will still be drawing, cause object enablers to load, infect other drawings.


If your end goal is to get rid of all the AEC stuff, and not have it affect other drawings, I dont think you have another option than creating a new drawing.
I did what MP already mention, I coded up a routine that takes all .dwg files in folder and batches the exporttoacad command placing them into a folder called "exported".

 

Within the Following, how can I get it to read "ExportToCAD - 20210802"?

 

 (setq sub "ExportToCAD - (substr (rtos (getvar "CDATE") 2 0) 3))"  ;; Subdirectory

 

Then towards the end of the routine I can activate the export command.

 

(command "_.-exporttoautocad" "F" "2010" "" "")

 

 

Posted (edited)
27 minutes ago, rcb007 said:

Within the Following, how can I get it to read "ExportToCAD - 20210802"?

 








 (setq sub "ExportToCAD - (substr (rtos (getvar "CDATE") 2 0) 3))"  ;; Subdirectory

 

Then towards the end of the routine I can activate the export command.

 








(command "_.-exporttoautocad" "F" "2010" "" "")

 

 

 

This will overwrite a file if it exits but not in use or create it if their isn't a file there.

(defun c:sav (/ cpy sub)
  (setq sub (substr (rtos (getvar "CDATE") 2 0) 3))  ;; Subdirectory
  (cond
    ((zerop (getvar 'dwgtitled))
            (princ "\nCurrent drawing is unsaved.")
    )
    ((not (or (findfile (setq sub (strcat (getvar 'dwgprefix) sub))) (vl-mkdir sub)))
          (princ (strcat "\nUnable to create directory " sub))
    )
    ((progn
        (princ "\nSaving current drawing...")
        (command "_.qsave")
        (setq cpy (strcat sub "\\" (substr (rtos (getvar "CDATE") 2 0) 3) "_" (getvar 'dwgname)))
        (if (findfile cpy)
          (vl-cmdf "_.-exporttoautocad" "_F" "2010" "" cpy "_Y")
          (vl-cmdf "_.-exporttoautocad" "_F" "2010" "" cpy)
        )
      )
    )
    (princ (strcat "\nUnable to expot drawing to: " cpy))
  )
  ((princ (strcat "\nDrawing exported to: " cpy)))
  (princ)
)

 

Edited by mhupp
Posted (edited)

Awesome... got one more question for you. Within the Folder Name. How can i get it to add this into it?

 

As for the export works great!

 

(setq sub "ExportToCAD - (substr (rtos (getvar "CDATE") 2 0) 3))" ;; Subdirectory

(setq sub (strcat (getvar "dwgprefix") "ExportToCAD-"(substr (rtos (getvar "CDATE") 2 0) 1)))  ;; Subdirectory

 

Edited by rcb007
Posted

You want the sub folder to be?

ExportToCAD - YYYYMMDD

and the file to be

YYMMDD_ dwgname

 

 

  • Thanks 1
Posted

Sorry for not getting back to you sooner. That is what I was going for and I think I figured it out.

 

(defun c:sav (/ cpy sub)
(setq sub (strcat "ExportToAutoCAD-" (substr (rtos (getvar "CDATE") 2 0) 1)))
  (cond
    ((zerop (getvar 'dwgtitled))
            (princ "\nCurrent drawing is unsaved.")
    )
    ((not (or (findfile (setq sub (strcat (getvar 'dwgprefix) sub))) (vl-mkdir sub)))
          (princ (strcat "\nUnable to create directory " sub))
    )
    ((progn
        (princ "\nSaving current drawing...")
        (command "_.qsave")
        (setq cpy (strcat sub "\\" (substr (rtos (getvar "CDATE") 2 0) 1) "-ACAD-" (getvar 'dwgname)))
        (if (findfile cpy)
          (vl-cmdf "_.-exporttoautocad" "_F" "2010" "" cpy "_Y")
          (vl-cmdf "_.-exporttoautocad" "_F" "2010" "" cpy)
        )
      )
    )
    (princ (strcat "\nUnable to expot drawing to: " cpy))
  )
  ((princ (strcat "\nDrawing exported to: " cpy)))
  (princ)
)

 

 

Thank you again for all your help!!!

  • Agree 1

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