Looping through Drawings Problem (VL Namespace Mismatch)

Anonymous

Looping through Drawings Problem (VL Namespace Mismatch)

Anonymous
Not applicable

I have recently upgraded to AutoCAD 2017 (from AutoCAD 2012) and am struggling to run a routine that was previously fine (in 2012)

The Routine was used to loop through any number of drawings, perform a task and then move on to the next..

The bones of this routine are below,,  The Error I now receive is "***INTERNAL ERROR: VL Namespace Mismatch Type Y to Reset" after the first drawing is opened..  it then stops.  If the code is pasted in line by line into the command window, it appears to function without a hitch.  Any clues or suggestions would be very welcome.

 

(defun c:looptest ()
 (vl-load-com)
 (setvar "lispinit" 0)
 (setvar "sdi" 1)
 (setq dwglist (list "c:\\temp\\a.dwg" "c:\\temp\\b.dwg"))
 (repeat (length dwglist)
  (vla-zoomextents (vlax-get-acad-object))
  (vl-cmdf "open" "y" (car dwglist))
  (vla-zoomextents (vlax-get-acad-object))
  (alert (getvar "dwgname"))
  (setq dwglist (cdr dwglist))
 )
 (alert "Complete")
 (setvar "sdi" 0)
)

0 Likes
Reply
1,367 Views
10 Replies
Replies (10)

dbroad
Mentor
Mentor

I'm kind of surprised that that code ever worked.

1) If SDI mode is set to 1 in the middle of an executing program, it would cause problems with any other currently open drawings.

2) Internal autolisp variable and the code executing will be lost as soon as the open command was executed. So in the next drawing, dwglist wouldn't exist.

It might be possible to use a bb* function to store and recall a list between drawings but I'm not sure that works in SDI.

 

I have always used programs like this to write a script file and then run the script file.

 

SCRIPTPRO with the AcCoreConsole is a better option for batch processing files now.

Architect, Registered NC, VA, SC, & GA.
0 Likes

Anonymous
Not applicable

Thanks dbroad.  for the reply.  The program is only ever intended to run as a one-off batch process, and is never called from within another function, so  the 'SDI' restriction isn't really an issue for me (as long as I kick it off with only one open drawing). 

With 'LISPINIT' set to zero, the AutoLisp variables would previously have endured through a limitless number of drawings opening and closing (I have run this over several hundred drawings with no problem, and have used it hundreds of times (in Acad 2012)).

There appears to be a change in more recent releases with the LISPINIT setting/variable, and I think you're absolutely right that it's the loss of the variable 'dwglist' that's causing my routine to fail.

Several people have suggested the 'script file' option to me, but that just seems a bit of a drama and going backwards when you consider that the function ran perfectly on an earlier version of AutoCAD.

I take your points and will investigate the SCRIPTPRO Route..  Much Appreciated.

0 Likes

dbroad
Mentor
Mentor

LISPINIT was only available for R14-2005. It was only settable when SDI was 1 as you know from this 2003 discussion.

 

Architect, Registered NC, VA, SC, & GA.
0 Likes

Anonymous
Not applicable

LISPINIT does work in 2012.  With LISPINIT set to 0, the lisp variables are retained and routine Runs, with LISPINIT set to 1 it doesn't.  I'm assuming something's happened between 2012 and 2017 to LISPINIT.

0 Likes

dbroad
Mentor
Mentor

Hmm. Surprising.  I got my info on the date range of the system variables from Hyperpics.  Some variables are made obsolete and continue to work regardless.  I just tested it in 2017, setting LISPINIT to 0 and SDI to 1. I then (setq test '(1 2 3 4 5)) and then started the new command.  !test in the new drawing returned the list so it still must be working in 2017.  Haven't checked 2018 yet though.

 

I would still recommend using SCRIPTPRO.

Architect, Registered NC, VA, SC, & GA.
0 Likes

Anonymous
Not applicable

Thanks for the Advice..  I'll give SCRIPTPRO a try...

0 Likes

Anonymous
Not applicable

Strange thing is, If you attempt to do what you've described above, but doing it using Lisp instead of typing at the command line, you will probably get the "VL Namespace Mismatch" Error appear..

0 Likes

ambrosl
Autodesk
Autodesk

@Anonymous wrote:

Hmm. Surprising.  I got my info on the date range of the system variables from Hyperpics.  Some variables are made obsolete and continue to work regardless.  I just tested it in 2017, setting LISPINIT to 0 and SDI to 1. I then (setq test '(1 2 3 4 5)) and then started the new command.  !test in the new drawing returned the list so it still must be working in 2017.  Haven't checked 2018 yet though.

 

I would still recommend using SCRIPTPRO.


I checked the website (http://www.hyperpics.com/system_variables/index.asp) and LISPINIT was still available the last time I updated my database for AutoCAD 2013.  I need to find some time to update it to the latest release though.  I do agree though, utilizing SCRIPTPRO would be a much safer option going forward.



Lee Ambrosius
Senior Principal Content Experience Designer
For additional help, check out the AutoCAD Developer Documentation
0 Likes

dbroad
Mentor
Mentor

Thanks @ambrosl (Lee),

I appreciate the link and the update info.  The link I referred to was using was:

http://hyperpics.com/system_variables/downloads/AutoCAD_System_Variables.pdf.  I hadn't noticed that it was only applicable through 2005.

 

There does not appear to be any help documentation though on LISPINIT and it is no longer listed in the system variables list.  Those are signs that it has been made obsolete.

Architect, Registered NC, VA, SC, & GA.
0 Likes

nate_holt
Explorer
Explorer

I found that temporarily saving and turning off DEMANDLOAD (setq sav_DEMANDLOAD_val (getvar "DEMANDLOAD")) and turning it off (setvar "DEMANDLOAD" 2), then doing my operations that were prone to trigger the error, and then setting DEMANDLOAD back to its saved value when finished, the failure seemed to be avoided. Nate Holt - N8 Consultants LLC.

0 Likes