Kraut1976 Posted August 23, 2011 Share Posted August 23, 2011 (edited) I have a script file that functions correctly with AutoCAD 2011, but not AutoCAD 2012. Here is a portion of said script. _OPEN "I:\Wr\ANYTOWN\DETAILS\TB.dwg" (setq date1 (vl-registry-read "HKEY_CURRENT_USER\\Software\\BGUpload\\WMSPProtoChangeDates\\" "date1")) (setq date2 (vl-registry-read "HKEY_CURRENT_USER\\Software\\BGUpload\\WMSPProtoChangeDates\\" "date2")) (setq ss1 (ssget "_w" '(40.9 11.5) '(41.75 11.7))) (setq ss2 (ssget "_w" '(40.9 10.9) '(41.75 11.1))) (setq txtent1 (ssname ss1 0)) (setq txtent2 (ssname ss2 0)) (setq txtobj1 (vlax-ename->vla-object txtent1)) (setq txtobj2 (vlax-ename->vla-object txtent2)) (vlax-put-property txtobj1 "TextString" date1) (vlax-put-property txtobj2 "TextString" date2) (vlax-release-object txtobj1) (vlax-release-object txtobj2) (setq ss1 nil) (setq ss2 nil) qsave close In AutoCAD 2012, it will open the drawing but it will not execute the lines after that. I just don't understand why it would function in one but not the other. Any suggestions? Edited August 23, 2011 by SLW210 Add code tags! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 Welcome to CADTutor! Can you tell me what error is received at the command line (if any), when the script stops executing? Where is (vl-load-com)? Also, please use . Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 It doesn't throw any error it just opens the first drawing and then stops. I have tried copying the lisp code directly to the command line and it all functions correctly in 2012. I wasn't aware that it was still necessary to do a vl-load-com. I thought they started loading that automatically a few releases back? I'll give that a shot though. And sorry about the code thing. I should have perused the forum rules a little more closely. Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 I tried adding a (vl-load-com) and even an (alert "marker") right after that. It opens the file but my marker alert doesn't fire. It doesn't seem that any of my code runs after the open. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 No worries. (vl-load-com) is required for all Visual LISP code. Most typically add this to ACADDOC.lsp so it's loaded automatically for each drawing opened. If (vl-load-com) IS the issue, then the code would not have worked when pasted to the command line. While your code could use some simplification, you might try using a single forward slash "/" in lieu of a single back-slash "\" with scripts. Note that LISP accepts only single forward-slash "/", or double back-slashes "\\". Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 Does the registry key you're trying to read exist? Edit: "vl-load-com" will not work, "(vl-load-com)" is required (without the quotes). Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 The registry key does exist. Everything works if I copy it line by line from the script to the command line. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 The registry key does exist. Everything works if I copy it line by line from the script to the command line. If the code works when pasted to the command line, then there is something wrong with the .SCR file contents. Have you considered having the script call a LISP function (defun) instead of including the LISP code within the script itself? Pseudo code: ._open "[color=red]<FilePath>[/color]/[color=red]<FileName>[/color].dwg" (load "[color=red]<FilePath>[/color]/[color=red]<FileName>[/color].lsp") [color=red]<CommandName>[/color] ._qsave ._close Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 I don't believe that there is a problem with the script contents. I'm just trying to call base autolisp functions. They are not contained in a specific .lsp file. Here is a simple example that I just tried. _OPEN "C:\Test\Test.dwg" (alert "marker") qsave close Again, it opens the file just fine but nothing functions after that. Perhaps there is an issue with running lisp functions inside a script in AutoCAD 2012? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 Sorry Kraut, I've tested that script (replacing the filepath, filename) and all is working on my end. Edit: The only thing I added to your script posted above, was a space after "close" Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 Interesting... Maybe it's somehow related to me now running AutoCAD 2012 on a Windows 7 64 bit computer? (I guess I should have stated that to begin with.) At any rate, thank you to everyone that responded to my post! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 Interesting... Maybe it's somehow related to me now running AutoCAD 2012 on a Windows 7 64 bit computer? (I guess I should have stated that to begin with.) I'm using Windows 7 Land Desktop 2009 (32-Bit), and Civil 3D 2011 (64-Bit). At any rate, thank you to everyone that responded to my post! Yeah, I'm the only person who responded. So, you're welcome? LoL Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 After further testing on other computers in my office it appears that the issue lies not with AutoCAD but with my Windows 7 permissions. The script will process on computers with Acad 2012 with Windows XP as well as Acad 2012 with Windows 7. Just not on my computer. Grrrr... Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 23, 2011 Share Posted August 23, 2011 I'm not sure what could be causing that though... Your script won't load an alert message? Quote Link to comment Share on other sites More sharing options...
Kraut1976 Posted August 23, 2011 Author Share Posted August 23, 2011 That is correct, sir. It works flawlessly on every computer in the office except for mine. Danged old ghost in the machine... Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted August 23, 2011 Share Posted August 23, 2011 That is correct, sir.It works flawlessly on every computer in the office except for mine. Danged old ghost in the machine... Be careful, you'll have a faceless robot running amok and throwing people off the top floor! Quote Link to comment Share on other sites More sharing options...
Patrick Hughes Posted August 23, 2011 Share Posted August 23, 2011 That is correct, sir.It works flawlessly on every computer in the office except for mine. Danged old ghost in the machine... It's likely not hanging at the alert but at reading the registry key. If you are on 64 bit is it looking at the real key or the virtualized key? I'm not sure what BGUpload\\WMSPProtoChangeDates is but if it is from a 32 bit application the actual working key may be under a different branch in the registry: something like (wow32). Quote Link to comment Share on other sites More sharing options...
Patrick Hughes Posted August 27, 2011 Share Posted August 27, 2011 Hey I just had a thought. Is it possible your script is being saved as Unicode (or UTF- 8 rather than ANSI text? Could that be the problem if so? Edit > I suppose if that's the case it wouldn't run on other machine now that I've thought more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.