View Full Version : Functions that worked in AutoCAD 2004 no longer work in AutoCAD 2007
sthedens
2007-05-03, 07:18 PM
We have a highly configured enviornment in 2004 and are in the process of migrating to 2007. In testing out 2007 we have encountered a problem. We have some functions that call commonly used functions in a separate lisp file. The function LABEL has the following segment of code:
(setq SYM_LAY "PANNO")
(lyr_set sym_lay)
The function LYR_SET has the following segment of code:
(defun LYR_SET ( LYRLINK / LAY_CANCL)
When the LABEL function calls LYR_SET the following error occurs:
Error: bad arguement type: FILE "PANNO"
It appears the LYR_SET function is expecting a FILE parameter rather than a String.
These routines work fine in 2004 but not 2007.
Probably need to see more of your code, but the layer link may be a link to a previously opened file which has not been closed.
sthedens
2007-05-03, 09:34 PM
Here is more (not all) of the code:
LABEL function:
(if (= "PL" (strcase (substr (getvar "dwgname") 1 2)))
;then
(setq SYM_LAY "PANNO")
;else
(if (= "PI" (strcase (substr (getvar "dwgname") 1 2)))
;then
(setq SYM_LAY "MANNO")
;else
(setq SYM_LAY nil)
);end if
);end if
(if SYM_LAY
(progn
(LYR_SET SYM_LAY) ;;<----This is the function call that triggers the error
(command ".BREAK" TXT_PT "F"
(polar TXT_PT TXT_ANG (/ brk_dist 2))
(polar TXT_PT (+ PI TXT_ANG) (/ brk_dist 2))
)
)
(progn
(command "LAYER" "S" LYR_NM "" "COLOR" CLR ".BREAK" TXT_PT "F"
(polar TXT_PT TXT_ANG (/ brk_dist 2))
(polar TXT_PT (+ PI TXT_ANG) (/ brk_dist 2))
)
)
)
LYR_SET function:
(Defun LYR_SET ( LYRLINK / LAY_CANCL) ;;<------This is where the error occurs.
(setq LYR (assoc LYRLINK LYRLINK_LST))
(if LYR
(progn
(cond
((= CONST_TYPE "NEW")
(if (= (tblsearch "ltype" (last LYR)) nil)
(command ".linetype" "load" (last LYR) "ACAD" "")
)
(if (= (tblsearch "layer" (caddr LYR)) nil)
(progn
(defun do_exit ()
(done_dialog 1)
)
(setq SRT (load_dialog (strcat AECAD_PATH "COMN/LAYERMAKE")))
(new_dialog "LAYERMAKE" SRT)
(action_tile "cancel" "(setq LAY_CANCL 1)(do_exit)")
(Start_dialog)
(unload_dialog SRT)
(if (/= LAY_CANCL 1)
(command "-layer" "MAKE" (strcat (caddr LYR) "") "COLOR" (cadddr LYR) "" "LT" (last LYR) "" "")
)
)
(command "-layer" "SET" (strcat (caddr LYR) "") "")
)
)
((= CONST_TYPE "EXST")
(if (= (tblsearch "ltype" (last LYR)) nil)
(command ".linetype" "load" (last LYR) "ACAD" "")
)
(command "-layer" "MAKE" (strcat (caddr LYR) "-EXST") "COLOR" "8" "" "LT" (last LYR) "" "")
)
((= CONST_TYPE "DEMO")
(if (= (tblsearch "ltype" "DASHED2") nil)
(command ".linetype" "load" "DASHED2" "ACAD" "")
)
(command "-layer" "MAKE" (strcat (caddr LYR) "-DEMO") "COLOR" (cadddr LYR) "" "LT" "DASHED2" "" "")
)
)
)
; (exit)
)
(princ)
)
Tom Beauford
2007-05-04, 12:12 PM
We have a highly configured enviornment in 2004 and are in the process of migrating to 2007. .Gotta ask, why not upgrade to the current version 2008?
Try adding lines like "\nGot this far!" in the function where the error occurs to see exactly where. Does the dialog box display?
sthedens
2007-05-04, 01:44 PM
Our company isn't mobile regarding decisions to upgrade (like trying to turn the Queen Mary). So 2008 is out of the question for now.
I had already embedded flags in the code to determine where the error is occurring. I removed those flags once I determined the culprit. I commented the code segments where the problem occurs. The problem is the function call (LYR_SET SYM_LAY). The SYM_LAY variable contains String information. The function LYR_SET seems to be expecting a File parameter rather than the String parameter it is receiving.
The first line in your LYR_SET routine is using the assoc function. This function looks for an element (LYRLINK) within a list (LYRLINK_LST). You do not show where LYRLINK_LST is defined.
Have you tried the VLIDE (Visual Lisp integrated development environment)? It will allow you to step through your routines and display the values of variables within the Watch window. You will want to place a break point somewhere close to where you think the error is located. When you run your routine, the VLIDE will break execution once it reaches a break point.
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.