2000 lisp to 2005 problem

Discussion in 'AutoCAD' started by andrewg, Jul 19, 2004.

  1. andrewg

    andrewg Guest

    The following is a very basic lisp routine I did ages ago that looks for a OS map file (specified by the user) and insets it at 0,0, zooms to extents, and then turns off a load of layers. This has stopped working in 2005 because of the way the '-inset' command works (after autocad cant find the file in the support folders it halts the routine instead of going onto the next line, like in 2000). I need the routine to go onto the next line and ignore any path finding errors it comes across. I'm afraid I dont know much about Lisp so any help would be much appreciated.

    ;Map creator by A. Gartland
    ;
    (defun C:map ( )
    ;
    ;First enter map filenames...
    ;
    (setq map1 (getstring "\nEnter grid reference or ESC to cancel:"))
    ;
    ;Next insert the map blocks then zoom to extents & freeze unwanted layers...
    ;
    (command "cmdecho" "1")
    (command "-insert" map1 "0,0" "" "" "")
    (command "-insert" (strcat map1 "ne") "0,0" "" "" "")
    (command "-insert" (strcat map1 "se") "0,0" "" "" "")
    (command "-insert" (strcat map1 "nw") "0,0" "" "" "")
    (command "-insert" (strcat map1 "sw") "0,0" "" "" "")
    (command "zoom" "e")
    (command "-layer" "f" "TPCL,NCTR,P_BY,E_BY,O_PK,R_CL,B_PT,TBLD,TEXT,T_BY,GRID,COPYRIGHT,GRIDTEXT,TXT_GRID,HEADER,SCRU,VEGS,TRIG,HTPT,BMER,WTER,NCTS,RGRA,MRSH,NCON,SLOP" "")
    (repeat 1)
    )(princ)
     
    andrewg, Jul 19, 2004
    #1
  2. to test for valid filenames -
    (if (findfile map) (command "-insert" map "0,0" "" "" ""))
    (if (findfile (strcat map1 "ne")) (command "-insert" (strcat map1 "ne")
    "0,0" "" "" ""))

    also, I don't see a purpose for the line (repeat 1)
     
    Alan Henderson @ A'cad Solutions, Jul 19, 2004
    #2
  3. andrewg

    andrewg Guest

    Thanks for the help, I will try that. As for the (repeat 1) bit... As I said, I don't know much about Lisp :¬Z ... I'm not sure why I put it in there, It was quite a while ago.
     
    andrewg, Jul 19, 2004
    #3
  4. andrewg

    andrewg Guest

    Ok, my routine now looks as follows:

    ;Map creator by A. Gartland
    ;
    (defun C:map ( )
    ;
    ;First enter map filenames...
    ;
    (setq map1 (getstring "\nEnter grid reference or ESC to cancel:"))
    ;
    ;Next insert the map blocks then zoom to extents & freeze unwanted layers...
    ;
    (command "cmdecho" "1")
    (if (findfile map1) (command "-insert" map1 "0,0" "" "" ""))
    (if (findfile (strcat map1 "ne")) (command "-insert" (strcat map1 "ne") "0,0" "" "" ""))
    (if (findfile (strcat map1 "se")) (command "-insert" (strcat map1 "se") "0,0" "" "" ""))
    (if (findfile (strcat map1 "nw")) (command "-insert" (strcat map1 "nw") "0,0" "" "" ""))
    (if (findfile (strcat map1 "sw")) (command "-insert" (strcat map1 "sw") "0,0" "" "" ""))
    (command "zoom" "e")
    (command "-layer" "f" "TPCL,NCTR,P_BY,E_BY,O_PK,R_CL,B_PT,TBLD,TEXT,T_BY,GRID,COPYRIGHT,GRIDTEXT,TXT_GRID,HEADER,SCRU,VEGS,TRIG,HTPT,BMER,WTER,NCTS,RGRA,MRSH,NCON,SLOP" "")
    )(princ)

    The routine is not performing the '-insert' command and skipping straight to the 'zoom' command so I assume 'findfile' cant find the appropriate file. I definately have the correct dir listed in my support folders and the files (which look like: se5503.dwg, se5504ne.dwg, se5504nw.dwg, etc...) definately exist. Am I doing something wrong. Thanks in advance.
     
    andrewg, Jul 19, 2004
    #4
  5. andrewg

    ECCAD Guest

    The 'findfile' function is a means to find a file. The file (extension) must be supplied (e.g. map1.dwg)..in order for the findfile to 'find' it.
    So, for an example, change:
    (if (findfile (strcat map1 "ne")) (command "-insert" (strcat map1 "ne") "0,0" "" "" ""))
    To:
    (if (findfile (strcat map1 "ne" ".dwg")) (command "-insert" (strcat map1 "ne") "0,0" "" "" ""))
    Note where the '.dwg' goes.

    Bob
     
    ECCAD, Jul 19, 2004
    #5
  6. andrewg

    andrewg Guest

    My routine now looks like this:


    ;Map creator by A. Gartland
    ;
    (defun C:map ( )
    ;
    ;First enter map filenames...
    ;
    (setq map1 (getstring "\nEnter grid reference or ESC to cancel:"))
    ;
    ;Next insert the map blocks then zoom to extents & freeze unwanted layers then purge unused layers...
    ;
    (command "cmdecho" "1")
    (if (findfile (strcat map1 ".dwg")) (command "-insert" map1 "0,0" "" "" ""))
    (if (findfile (strcat map1 "ne" ".dwg")) (command "-insert" (strcat map1 "ne") "0,0" "" "" ""))
    (if (findfile (strcat map1 "se" ".dwg")) (command "-insert" (strcat map1 "se") "0,0" "" "" ""))
    (if (findfile (strcat map1 "nw" ".dwg")) (command "-insert" (strcat map1 "nw") "0,0" "" "" ""))
    (if (findfile (strcat map1 "sw" ".dwg")) (command "-insert" (strcat map1 "sw") "0,0" "" "" ""))
    (command "zoom" "e")
    (command "-layer" "f" "TPCL,NCTR,P_BY,E_BY,O_PK,R_CL,B_PT,TBLD,TEXT,T_BY,GRID,COPYRIGHT,GRIDTEXT,TXT_GRID,HEADER,SCRU,VEGS,TRIG,HTPT,BMER,WTER,NCTS,RGRA,MRSH,NCON,SLOP" "")
    (command "-purge" "la" "*" "n")
    )(princ)


    ...and works perfectly! Thankyou to everyone for your help.
     
    andrewg, Jul 20, 2004
    #6
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.