bind and save to dir 3 levels up lisp

Discussion in 'AutoCAD' started by devon, Jun 30, 2004.

  1. devon

    devon Guest

    Hi,

    I have made this lisp, but It seems to fall over.
    our proj dir is like so:

    ProjNumber
    DocumentControl
    Outgoing
    To Be Issued
    Drawings
    Structural
    Mechanical
    etc etc

    My idea was to have a lisp called "issue" that binds & purges and then saves from the "structural dir" to the "doc control\outgoing\to be issued dir" ready for plotting/archive

    What am i doing wrong?

    (defun c:Issue ()
    (command "xref" "b" "*")
    (command ".purge" "a" "" "n")
    (command ".purge" "a" "" "n")
    (command ".purge" "a" "" "n")
    (command
    "saveas"
    "2000"
    (strcat
    (vl-filename-directory
    (vl-filename-directory
    (getvar "dwgprefix")
    )
    )
    (strcat projpref (nth project_val projnm_sym) ;server proj path dir to project
    "/documentcontrol/outgoing/to be issued/"
    (getvar "dwgname")
    )
    )
    )
    (princ)
    )
    Any help would be great!
     
    devon, Jun 30, 2004
    #1
  2. devon

    zeha Guest

    devon,

    check the follow:

    (alert(strcat
    (vl-filename-directory
    (vl-filename-directory
    (getvar "dwgprefix")
    )
    )
    (nth project_val projnm_sym)
    "/documentcontrol/outgoing/to be issued/"))

    or the next if statement returned T
    I think it's var projpref witch perhaps is nil

    (vl-file-directory-p (strcat
    (vl-filename-directory
    (vl-filename-directory
    (getvar "dwgprefix")
    )
    )
    (nth project_val projnm_sym)
    "/documentcontrol/outgoing/to be issued/"))
     
    zeha, Jun 30, 2004
    #2
  3. devon

    devon Guest

    Hi Zeha,

    Seems like you must be the man for the job?!!
    Thanks for you help.

    I have to admit that i'm confused with your solution and didnt have much success.

    I went back to my origional code and got it working like so...
    -----------------------------------------
    (defun c:Issue ()
    (command "xref" "b" "*")
    (command ".purge" "a" "" "n")
    (command
    "saveas"
    "2000"
    (strcat projpref (nth project_val projnm_sym) ;server proj path dir to project
    "/documentcontrol/outgoing/to be issued/"
    (getvar "dwgname")
    )
    )
    (princ)
    )
    -------------------------------------------------
    Only problem is that it saves the bound/purged dwg to both the live dir and the 'to be issued' dir.

    Maybe I need to qsave to current and then saveas to the issue dir? not sure how to get it to change dir and also not overright the current unbound file.

    Thanks for your input.
     
    devon, Jul 1, 2004
    #3
  4. devon

    zeha Guest

    Devon,

    Have you checked the follow code
    Just copy between paranteses and pasted on the command line
    it returns or nil or T

    T means that the subdirectory exist
    nil means that the subdirectory not exist

    if it is nil look at all your variable (it must be strings or list of strings) like
    project_val
    projnm_sym
    and (nth project_val projnm_sym)
    projpref
     
    zeha, Jul 1, 2004
    #4
  5. devon

    ECCAD Guest

    In the following sequence:
    (strcat projpref (nth project_val projnm_sym) ;server proj path dir to project
    "/documentcontrol/outgoing/to be issued/"
    (getvar "dwgname")

    Try shortening the 'dwgname' - eliminate the '.dwg'.
    (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname") 4)))

    Bob
     
    ECCAD, Jul 1, 2004
    #5
  6. devon

    devon Guest

    Thanks for the reply guys :)

    This is what I ended up with...

    (defun c:Issue ()
    (command "xref" "b" "*")
    (command ".purge" "a" "" "n")
    (vl-file-directory-p (strcat projpref
    (vl-filename-directory
    (vl-filename-directory
    (getvar "dwgprefix")
    )
    )
    (command
    "saveas"
    "2000"
    (strcat projpref (nth project_val projnm_sym) ;server proj path dir to project
    "/documentcontrol/outgoing/to be issued/"
    (getvar "dwgname")
    )
    )
    )
    )
    (princ)
    )

    Works fine, but I get this error up the cmd line just b4 the end of the routine...
    ; error: bad argument type: stringp nil

    Thanks
     
    devon, Jul 2, 2004
    #6
  7. devon

    ECCAD Guest

    What is in variable 'projnm_sym' when it fails..?..and 'project_val' ?

    Bob
     
    ECCAD, Jul 2, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.