Jump to content

Recommended Posts

Posted

I have a lisp right now that opens explore to the location of the current drawing open.

 

(defun c:xpl ()
 (startapp "explorer" (strcat "/n,/e," (getvar "dwgprefix")))
 (princ)
)

 

Let’s say the location is:

 

J:\2008\01080\dwgs\electrical

 

I am trying to get it to do the following:

 

1. Bind and purge the Current drawing.

 

2. Ask user Where to Save? Bound or E-Mail

 

a. If boundis picked then save in this location with current name

 

J:\2008\01080\bound\ (Current Date)\ (Current Name).dwg

 

Note. If folder is not made already, create folder first. The date folder will be formatted like this 2008-09-30

 

b. If E-Mail is picked then save in this location with current name

 

J:\2008\01080\E-Mail\ (Current Date)\ (Current Name).dwg

 

Note. If folder is not made already, create folder first. The date folder will be formatted like this 2008-09-30.

 

 

3. Exit the Drawing

 

I hope this makes sense to someone other than me. Thanks in advance to everyone.

 

 

Posted

Its not pretty but this should get you started. It does not bind or purge the file but you should be able to add that. I only had about 10 minutes to work on it.

You should also add some error trapping.

I hope it helps.

(defun c:BindIt ( / )
(setq vDia (getvar "filedia")
      vEcho (getvar "cmdecho")
      vPrefix (getvar "dwgprefix")
      vName (getvar "dwgname")
      vDate (rtos (getvar "cdate") 2 6)
      vYear (substr vDate 1 4)
      vMonth (substr vDate 5 2)
      vDay (substr vDate 7 2)
      vDateStr (strcat vYear "-" vMonth "-" vDay)
)
(setvar "filedia" 0)
(setvar "cmdecho" 0)
(initget 1 "Bind Email")
(setq vAns (getkword "\nSave file to [Email / Bound] <Bound>: "))
(cond
 ((= "Bind" vAns)
  (setq vDir (strcat vPrefix "Bound"))
 )
 ((= "Email" vAns)
  (setq vDir (strcat vPrefix "Email"))
 )
)
(if (= (vl-file-directory-p vDir) nil)
 (progn
  (vl-mkdir vDir)
  (vl-mkdir (strcat vDir "\\" vDateStr))
 )
 (if (= (vl-file-directory-p (strcat vDir "\\" vDateStr)) nil)
  (vl-mkdir (strcat vDir "\\" vDateStr))
 )
)
(command ".saveas" "" (strcat vDir "\\" vDateStr "\\" vName))
(setvar "filedia" vDia)
(setvar "cmdecho" vEcho)
(princ)
)

Posted
Its not pretty but this should get you started. It does not bind or purge the file but you should be able to add that. I only had about 10 minutes to work on it.

You should also add some error trapping.

I hope it helps.

(defun c:BindIt ( / )
(setq vDia (getvar "filedia")
      vEcho (getvar "cmdecho")
      vPrefix (getvar "dwgprefix")
      vName (getvar "dwgname")
      vDate (rtos (getvar "cdate") 2 6)
      vYear (substr vDate 1 4)
      vMonth (substr vDate 5 2)
      vDay (substr vDate 7 2)
      vDateStr (strcat vYear "-" vMonth "-" vDay)
)
(setvar "filedia" 0)
(setvar "cmdecho" 0)
(initget 1 "Bind Email")
(setq vAns (getkword "\nSave file to [Email / Bound] <Bound>: "))
(cond
 ((= "Bind" vAns)
  (setq vDir (strcat vPrefix "Bound"))
 )
 ((= "Email" vAns)
  (setq vDir (strcat vPrefix "Email"))
 )
)
(if (= (vl-file-directory-p vDir) nil)
 (progn
  (vl-mkdir vDir)
  (vl-mkdir (strcat vDir "\\" vDateStr))
 )
 (if (= (vl-file-directory-p (strcat vDir "\\" vDateStr)) nil)
  (vl-mkdir (strcat vDir "\\" vDateStr))
 )
)
(command ".saveas" "" (strcat vDir "\\" vDateStr "\\" vName))
(setvar "filedia" vDia)
(setvar "cmdecho" vEcho)
(princ)
)

 

 

Is there any way to have it go back two folders to save the folder bound or e-mail?

 

Example: M:\1234\dwgs\electrical and I want it to save the folders in the 1234 folder that would be two folders. You can also think of it as the folder before the dwgs folder to. Thanks in advance for everything.

Posted

Not my code but here is one way.

You can even create a new folder.

(defun ALE_GetFolder (/ DirPat)
   (and (setq DirPat (getfiled "Browse for folder"
                               "Open a folder and click on SAVE"
                               " "
                               1
                     )
        )
        (setq DirPat (substr DirPat 1 (- (strlen DirPat) 31)))
   )
   DirPat
 )

Posted
Not my code but here is one way.

You can even create a new folder.

(defun ALE_GetFolder (/ DirPat)
   (and (setq DirPat (getfiled "Browse for folder"
                               "Open a folder and click on SAVE"
                               " "
                               1
                     )
        )
        (setq DirPat (substr DirPat 1 (- (strlen DirPat) 31)))
   )
   DirPat
 )

 

 

You lost me!

Posted
You lost me!

 

Does anyone know what I am talking about?

Posted
Out of town until Monday.

 

Sorry been busy.

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