Next or Prev.?

Discussion in 'AutoCAD' started by Rudy Tovar, Mar 5, 2004.

  1. Rudy Tovar

    Rudy Tovar Guest

    Stepping through a directory dwg files? or having to go back to previous
    dwgs?

    Try this simply utility, but compile as VLX.

    Please report any bugs you encounter to refine...

    (defun C:next (/ files name y)

    (setq files (vl-directory-files (getvar"dwgprefix") "*.dwg"))

    (if files
    (progn
    (setq files (acad_strlsort files)
    name (vl-position (getvar"dwgname") files)
    name (nth (1+ name) files)
    )
    (if (or
    (= (getvar"dbmod") 1)
    (= (getvar"dbmod") 5)
    )
    (progn
    (setq y (strcase (getstring "Save Drawing File? [N]o: ")))

    (if (= y "Y")
    (progn
    (command "qsave")
    (if name
    (command "open" (strcat (getvar "dwgprefix") name))
    )
    )
    (progn
    (command "open" "n" (strcat (getvar "dwgprefix") name))
    )
    )


    )
    (progn
    (if (= (getvar"dbmod") 0)
    (progn
    (if name
    (command "open" (strcat (getvar "dwgprefix") name))
    )
    )
    (progn
    (if name
    (command "open" "n" (strcat (getvar "dwgprefix") name))
    )
    )
    )

    )
    )
    )
    )
    (princ)
    )

    (defun C:prev (/ files name y)

    (setq files (vl-directory-files (getvar"dwgprefix") "*.dwg"))

    (if files
    (progn
    (setq files (acad_strlsort files)
    name (vl-position (getvar"dwgname") files)
    name (nth (- name 1) files)
    )
    (if (or
    (= (getvar"dbmod") 1)
    (= (getvar"dbmod") 5)
    )
    (progn
    (setq y (strcase (getstring "Save Drawing File? [N]o: ")))

    (if (= y "Y")
    (progn
    (command "qsave")
    (if name
    (command "open" (strcat (getvar "dwgprefix") name))
    )
    )
    (progn
    (command "open" "n" (strcat (getvar "dwgprefix") name))
    )
    )


    )
    (progn
    (if (= (getvar"dbmod") 0)
    (progn
    (if name
    (command "open" (strcat (getvar "dwgprefix") name))
    )
    )
    (progn
    (if name
    (command "open" "n" (strcat (getvar "dwgprefix") name))
    )
    )
    )

    )
    )
    )
    )
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi
     
    Rudy Tovar, Mar 5, 2004
    #1
  2. Rudy Tovar

    Dan Guest

    AutoCAD 2000i - doesn't work for me. Had loaded as straight LSP then
    compiled to FAS & VLX, and still didn't work.

    Command: next Unknown command "N". Press F1 for help.
    Unknown command "U:\DRAWINGS\STEELCASE\PLOT\SC_A8-2.DWG". Press F1 for
    help.

    Tried simply:
    Command: (findfile "u:\\drawings\\steelcase\\plot\\sc_a8-2.dwg")
    "U:\\drawings\\steelcase\\plot\\sc_a8-2.dwg"

    Command: (command "open" "u:\\drawings\\steelcase\\plot\\sc_a8-2.dwg")
    Unknown command "U:\DRAWINGS\STEELCASE\PLOT\SC_A8-2.DWG". Press F1 for
    help.
    nil

    Command: (command "-open" "u:\\drawings\\steelcase\\plot\\sc_a8-2.dwg")
    Unknown command "-OPEN". Press F1 for help.
    Unknown command "U:\DRAWINGS\STEELCASE\PLOT\SC_A8-2.DWG". Press F1 for
    help.
    nil

    I seem to recall that in MDI you need to use:
    (command "._VBASTMT" (strcat "AcadApplication.Documents.Open \"" (strcase
    file) "\""))

    ???

    However what would be most useful is a routine that closes current and opens
    next. I believe only VBA can do that.

    Dan

    --
    ;;; For reply, change numbers to decimal


     
    Dan, Mar 5, 2004
    #2
  3. Rudy Tovar

    Rudy Tovar Guest

    The utility was written orig. for R14. But what you're asking I've already
    done for 2000+ and actually we posted this some time ago on the newsgroup. I
    can't remember when though....


     
    Rudy Tovar, Mar 6, 2004
    #3
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.