hawstom Posted September 21, 2010 Share Posted September 21, 2010 Hi, guys. I'm pretty new here, and I'm most of all looking for just insight on this thread. I'm working with a CAD customization that successfully used the following method to pass data from AutoLISP to VBA in version 2004: In AutoLISP (command "-vbarun" "file.dvb!module.function" "arg1" "arg2" "arg3" "arg4" "arg5") In VBA arg1 = ThisDrawing.Utility.GetString(False) arg2 = ThisDrawing.Utility.GetString(False) arg3 = ThisDrawing.Utility.GetString(False) arg4 = ThisDrawing.Utility.GetString(False) arg5 = ThisDrawing.Utility.GetString(False) This approach is new to me as of today. I have also apparently discovered today that this approach doesn't work in version 2010. Questions: 1. Is anybody familiar with this approach, or where the original programmer may have learned it? 2. Can anybody confirm that this approach stopped working somewhere along the way? FYI, I realize assuming this approach is dead, I will need to pass the data via user setvar/getvars, registry entries, or files. Thanks! Tom Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 21, 2010 Share Posted September 21, 2010 I do not do very much VBA development, but this thread may lead you to a helpful outcome: http://www.cadtutor.net/forum/showthread.php?51976-Getting-the-last-command-typed-from-AutoCAD-via-.NET-program There's multiple pages, but it gets really good towards the end. Hope this helps! Quote Link to comment Share on other sites More sharing options...
hawstom Posted September 21, 2010 Author Share Posted September 21, 2010 That gives some additional possibilities. I'd, of course, be most interested in using the method with the greatest long run viability. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 21, 2010 Share Posted September 21, 2010 VB.NET then, perhaps? :wink: Quote Link to comment Share on other sites More sharing options...
hawstom Posted September 21, 2010 Author Share Posted September 21, 2010 Heh. We will see what the budget allows. I am primarily interested at the moment in confirming that this trick method they used was good, but is no longer good. My personal preference going forward would be to use ActiveX with Visual LISP. Tom Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 21, 2010 Share Posted September 21, 2010 Heh. We will see what the budget allows. Visual Studio Express, and the AutoCAD ObjectARX SDK's are *free*. I am primarily interested at the moment in confirming that this trick method they used was good, but is no longer good. Understood. I am relegated to using 2009 software at the moment, so I'm afraid I am not much help on this particular question. My personal preference going forward would be to use ActiveX with Visual LISP. ... A man after my own heart; Visual LISP (i.e., ActiveX COM API) is my language of choice, personally. But that doesn't stop me from 'chiming in' with VBA every now and then. :wink: Cheers! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 23, 2010 Share Posted September 23, 2010 Going back a couple of steps how are arg1-arg5 originaly given a value is it by another lisp program ? Can it be re written into VBA ? Can live in the same DVB If you on want 5 then maybe use the user variables users1-5 useri1-5 user1-5, Also i am sure this topic has been discussed before did you search. Quote Link to comment Share on other sites More sharing options...
hawstom Posted September 23, 2010 Author Share Posted September 23, 2010 Thanks for the kind words, RenderMan. Bigal, what I decided to to is go ahead and convert everything to pass the data using users5 as a comma-delimited list I easily parsed in VBA with the Split function. I think that's probably a more respectable way to do it that the arguments hack that no longer works. And it's more "local" and fleeting than a registry write and less messy than a file write. Quote Link to comment Share on other sites More sharing options...
hawstom Posted September 25, 2010 Author Share Posted September 25, 2010 (edited) Update: After considering everything, I switched directions and went with registry data storage and passing. It was just a lot easier. If I were developing for the world where I can't rely on vl-, I would probably use the User setvars or maybe even file writing, but for this in-house application, the registry seems best. For good programming practice, I wrote two functions each in Visual LISP and in VBA. Replace "MYAPP" with your application or company identifier. The reason this is good programming practice is that you may later change your mind about (or be forced by new software to change) how to store and pass data. Having the "engine" in central functions not only saves you typing today, but eases your changes later. Visual LISP (works great for persistent storage in Visual LISP alone too): ;;;SaveSetting saves a string value to the registry to be read by VBA or Visual LISP ;;;Usage: (MYAPP:SaveSetting "BasePath" (vl-file-directory (findfile "MYAPP.mnl"))) (defun MYAPP:SaveSetting (key setting) (vl-registry-write "HKEY_CURRENT_USER\\Software\\VB and VBA Program Settings\\MYAPP\\General" key setting ) ) ;;;GetSetting reads a string value from the registry as saved by VBA or Visual LISP ;;;Usage: (MYAPP:GetSetting "BasePath") (defun MYAPP:GetSetting (key) (vl-registry-read "HKEY_CURRENT_USER\\Software\\VB and VBA Program Settings\\MYAPP\\General" key ) ) VBA 'SaveSetting saves a string value to the registry to be read by VBA or Visual LISP 'Usage: SaveSetting "BasePath", "R:\AutoCAD\MYAPP" Public Function MYAPP:SaveSetting(Key As String, Setting As String) SaveSetting "MYAPP", "General", Key, Setting End Function 'GetSetting reads a string value from the registry as saved by VBA or Visual LISP 'Usage: BasePath = GetSetting("BasePath") Public Function MYAPP:GetSetting(Key As String) MYAPP:GetSetting = GetSetting("MYAPP", "General", Key) End Function Edited September 28, 2010 by hawstom 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.