Verifying folder structure

Discussion in 'AutoCAD' started by larsfram, Aug 21, 2004.

  1. larsfram

    larsfram Guest

    I am currently working on a lisp routine that will populate identical attributed blocks with information on multiple layout tabs. Since I'm working both on a work computer and home computer, the file locations for the various files that will be inserted into the drawing are different. I would like to write a simple "if" statement that would verify the file tree structure and setq a local variable for the prefix of the appropriate path name.

    something like this:

    (if '"e:autocad customization" ;if this location exists
    (setq prefix "e:/autocad customization") :eek:therwise
    (setq prefix "i:/precafm/acad/customization/lisp")
    )

    This way my lisp works on both machines without constantly changing the setq

    Lars
     
    larsfram, Aug 21, 2004
    #1
  2. larsfram

    ECCAD Guest

    Lars,
    Here ya go.
    ;(if '"e:autocad customization" ;if this location exists
    ;(setq prefix "e:/autocad customization") :eek:therwise
    ;(setq prefix "i:/precafm/acad/customization/lisp")
    ;)
    ;; Save this file as "checkpath.lsp", in both folders.

    (if (findfile "E:/autocad customization/checkpath.lsp")
    (setq prefix "E:/autocad customization/")
    (setq prefix "I:/precafm/acad/customization/lisp/")
    ); end if

    Bob
     
    ECCAD, Aug 21, 2004
    #2
  3. larsfram

    Jürg Menzi Guest

    Hi Lars

    Code:
    (defun GetBlockPath (Nme)
    (cond
    ((findfile (strcat "e:/autocad customization/" Nme)))
    ((findfile (strcat "i:/precafm/acad/customization/lisp/" Nme)))
    (T (alert (strcat "File '" Nme "' not found.")))
    )
    )
    
    Use:
    (GetBlockPath "MyFile.dwg")
    Returns:
    - One of both paths including the file name
    - Nil if file 'Nme' in both paths not found (incl. error message)

    Cheers
     
    Jürg Menzi, Aug 21, 2004
    #3
  4. larsfram

    Chuck Guest

    I'm replying, not to try to answer your question, but to compare notes with
    you about this project. A while back, I wrote a routine that finds all
    attributes in a drawing with a given tag, and updates their value. The
    interesting thing was that sometimes it found all attributes on all layouts,
    and sometimes it didn't. I think it was operating-system-dependent.
    Fortunately it does find attributes on all layouts on Windows XP, but I
    think it only found the attributes on one layout (plus model space) on NT4
    or 98 (I don't remember exactly). What it seems to boil down to is that
    this code:
    (ssget "x" '((0 . "INSERT")))
    can find all the blocks on all layouts in some cases and not in others.
    Have you run into anything like this?

    attributed blocks with information on multiple layout tabs. Since I'm
    working both on a work computer and home computer, the file locations for
    the various files that will be inserted into the drawing are different. I
    would like to write a simple "if" statement that would verify the file tree
    structure and setq a local variable for the prefix of the appropriate path
    name.
     
    Chuck, Aug 21, 2004
    #4
  5. larsfram

    jonesr Guest

    I always create a "virtual" drive on the home PC (Win2k or XP) by sharing a
    folder on my local drive and then mapping it to use the name of the drive at
    the office. Have you tried this?

    attributed blocks with information on multiple layout tabs. Since I'm
    working both on a work computer and home computer, the file locations for
    the various files that will be inserted into the drawing are different. I
    would like to write a simple "if" statement that would verify the file tree
    structure and setq a local variable for the prefix of the appropriate path
    name.
     
    jonesr, Aug 23, 2004
    #5
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.