Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP WITH ERROR TRAPPING ON LISP ROUTINE

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
US
I HAVE PASTED A ROUTINE THAT I NEED SOME HELP WITH. THIS ROUTINE WILL RUN ON SOME DRAWINGS AND ERROR OUT ON OTHERS. WHEN IT ERRORS THE COMMAND LINE SHOWS "VL-NAME SPACE MISMATCH". THE ERROR OCCURS AFTER THE PURGES AND CHANGE COMMANDS. IS THERE A PROBLEM WITH THE CODE I CAN NOT FIND? IF NOT CAN AN ERROR TRAP BE PUT IN TO "RESUME ON ERROR"?

(DEFUN C:FIXA22 ()
(command "layer" "thaw" "*" "" "")
(command "layer" "SET" "0" "" "");sets current layer
(COMMAND "PURGE" "ALL" "" "N")
(COMMAND "PURGE" "ALL" "" "N")
(COMMAND "PURGE" "ALL" "" "N")
(COMMAND "PURGE" "ALL" "" "N")
(COMMAND "PURGE" "ALL" "" "N")
(COMMAND "PURGE" "ALL" "" "N")
(command "CHANGE" "ALL" "" "p" "COLOR" "BYLAYER" "LW" "BYLAYER" "" "")
(command "layer" "FREEZE" "*" "" "")

;START OF XREF SECTION
(tblnext "BLOCK" T);sets pointer to top of block table
(setq Loop T)
(while Loop
(setq Bdata (tblnext "BLOCK"));;steps through table
(if (assoc 1 Bdata);;an xref path
(setq XrefName (cdr (assoc 2 Bdata))
Loop nil
)
);if
);while

;start of thawed A2 xreflayer list
(setq LayList '(
"A-FLOR-ELEV"
"A-FLOR-EVTR"
"A-FLOR-FCAB"
"A-FLOR-RMNA"
"A-FLOR-RMNU"
"A-FLOR-STRC"
"A-FLOR-STRS"
"A-FLOR-STRS-UPDN"
"A-FLOR-XSHT"
"A-GLAZ-EXTE"
"A-WALL"
"A-WALL-ACCP"
"A-WALL-ACLG"
"A-WALL-CLNG"
"A-WALL-COLS"
"A-WALL-EXTE"
"A-WALL-GLAZ"
"A-WALL-LOW"
"A-WALL-SLAB"
"A-WALL-STRC"
"VIEWPORT"
"XREF"));end of A2 xref thawed layer list

(foreach x LayList
(setq LayName (strcat XrefName "|" x))
(command "layer" "THAW" LayName "" "")
);foreach ;end of A2 THAW XREF section
;END OF XREF SECTION

;START OF THAW SECTION
(setq LayList '(
"A-CLNG-ACCS"
"A-CLNG-BKHD"
"A-CLNG-DETL"
"A-CLNG-DOOR"
"A-CLNG-EQPM"
"A-CLNG-EXJT"
"A-CLNG-GRID"
"A-CLNG-HOOD"
"A-CLNG-NGRD"
"A-CLNG-REFS"
"A-CLNG-SHTT"
"A-CLNG-SKYL"
"P-ANNO"
"viewport"
"XREF"));END OF THAWED LAYER LIST

(foreach x LayList
(setq LayName (strcat x))
(command "layer" "THAW" LayName "" "")
);foreach
;end of THAW section
(command "layer" "SET" "A-clng-grid" "" "");SETS CURRENT LAYER
(command "layer" "lock" "xref" "" "")
(command "layer" "plot" "n" "viewport" "" "")
(command "ltscale" "24")
(command "fillet" "R" "0" "")

(vl-Load-Com);START OF LAYER FILTER DELETE
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove
(vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object))))
"ACAD_LAYERFILTERS")))
(princ "\nAll layer filters have been deleted.")
(princ);clean exit
);defun;END OF LAYER FILTER DELETE
 
Hi vbcad,

I think you've got an extra return here:
Code:
(command "CHANGE" "ALL" "" "p" "COLOR" "BYLAYER" "LW" "BYLAYER" "" [red]""[/red])

Try this:

Code:
(command "CHANGE" "ALL" "" "p" "COLOR" "BYLAYER" "LW" "BYLAYER" "")

HTH
Todd
 
yep you are right. this did not solve the error problem on the drawing in question. i have run an audit and recover etc. and it finds no errors in the database. any idea what it could be?
 
Hi vbcad,

Sorry I'm afraid I don't know, VLISP and AutoLISP were always a pain to debug - (hence the reason I switched to VB/VBA). The only thing I might suggest is to put in princ statement after every line - a huge pain I know but that way you can check the value of each variable and you'll know exactly where the routine is faltering.

Even though you've run audits and recovers, it still doesn't mean there's not a problem, you might try creating a new drawing and insert one of your problem children into the new drawing and then see if it helps, or the tried and true wblock with a window, not a crossing and not an all option, and then run an audit/recover on the newly created wblock file - this will sometimes strip out the problem children. If you've got any 3D entities, check for any modeling errors, these can kill a routine.

The other option is to switch the routine to VB/VBA, at least you'll get better error handling.

HTH
Todd
 
thanks for the advice. I am not an expert on VBA or LISP for that matter. I can't find an error in the code itself which leads me to believe it is in the particular drawing. it may be a good thing to fix the individual drawings as they come up to alleviate problem drawings in the data base.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top