TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Fred Tomke on December 21, 2009, 10:56:40 AM
-
Hello,
how can I load a VLX using DEMANDLOAD like it is possible with ARX files?
I've tried this but without success:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.2\ACAD-7000:407\Applications\LVMAN]
"Loader"="C:\\Programme\\LVMAN\\LVMAN.vlx"
"Description"="LVMAN"
"LoadCtrls"=dword:0000000c
[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.2\ACAD-7000:407\Applications\LVMAN\Commands]
"LVMAN"="LVMAN"
Fred
-
Welcome to the Swamp...
I thought AutoLoad would handle that?
I'll go look it up.
-
Hi, CAB, thanks for replying.
As far as I understood AUTOLOAD is that I have to start a lisp (in each drawing?) where the AUTOLOAD-expression has to be started. But I may be wrong.
The problem is that the path of the VLX is not an AutoCAD supportpath. I read it from the registry first. Where shall I start the lisp file with the AUTOLOAD-expressions, when I did not use the AutoCAD-supportpaths?
The advantage of such a registry key (like in my initial posting) is that I can set it during installation of the application. Then I have the installation path and I can loop through all the installed AutoCAD-installations.
Thank you for further hints or corrections.
Fred
-
Morning Fred, Welcome !
Have a look around, stay awhile :)
I'm sure that Owen has an app/method on his site to allow demand loading of VLX.
-
Have a look here
http://www.manusoft.com/cgi-bin/NoFrames.pl?referer=http://www.manusoft.com/resources/ARXTips/Index.stm&header=Header.stm&toc=TOC.stm&main=Main.stm#DemandLoadVLX
I haven't tried it 'cause I use Autoloading defined from my MNL's
-
Thanks Kerry, I'll try it out.
Fred
-
Here's a way to do it with a modified Autoload, 'cause the AutoCAD autoload doesn't like qualified pathing
First:
copy these to a file that loads into autoCAD at startup and into each Document ; either a MNL file or one of the ACADxxxxxx.lsp files.
I use a .MNL to a do-nothing .MNU file.
(vl-load-com)
(defun _FredsAutoAppload (app_name cmdlist / qapp initstring)
(setq qapp (vl-prin1-to-string app_name)
initstring "\nInitializing..."
)
(mapcar '(lambda (cmd / cmd_name)
(progn (setq cmd_name (strcat "C:" cmd))
(if (not (eval (read cmd_name)))
(eval (read (strcat "(defun " cmd_name
"( / rtn)" "(setq m:err *error* *error* *merrmsg*)"
"(if (findfile " qapp
")" "(progn (princ initstring)"
"(load " qapp
") (setq rtn (" cmd_name
")))" "(ai_nofile "
qapp "))"
"(setq *error* m:err m:err nil)"
"rtn)"
)
)
)
)
)
)
cmdlist
)
nil
)
;;-----------------------------------------------------------------------------
(setq FredsSpecialAppPath "K:/KDUBPro2010/TestLoad/")
(_FredsAutoAppload (strcat FredsSpecialAppPath "testload_01.lsp") '("testload_01"))
(_FredsAutoAppload (strcat FredsSpecialAppPath "Application2/testload_02.lsp") '("testload_02"))
;;-----------------------------------------------------------------------------
Then change the Pathing to suit your app location.
K:/KDUBPro2010/TestLoad/ is my app root path ( not on the ACAD PATH)
K:/KDUBPro2010/TestLoad/Application2/ is the folder for one of my apps
NOW :
when you start an AutoCAD drawing the placeholder command for each of your APPS is defined.
When you run the command at the commandline the app is loaded ( if not already loaded) and runs.
let us know how you get on
(defun c:testload_01 () (alert "We're inside TestLoad_01") (princ))
(princ)
(defun c:testload_02 () (alert "We're inside TestLoad_02") (princ))
(princ)
-
So, using your initial post,
your AppName would be
"C:\\Programme\\LVMAN\\LVMAN.vlx"
and your command would be "LVMAN"
so the placeholder definition call would/could be
(_FredsAutoAppload "C:\\Programme\\LVMAN\\LVMAN.vlx" '( "LVMAN"))
-
just an additional note
When you install your app you could save the appPath into the Registry ; then recall it to a Global variable into each document ... that way any support files can be found via the global variable for each applcation path.
-
Kerry, thank you so much!
Meanwhile I got Owen's code working for me and I created some ARX-files for DEMANDLOAD. Works very well.
The only thing I have to solve is how to load the lisp once for the first time to load the menu automatically.
I will also have a test with your samples. Looks very easy so I'm thinking about removing Owen's VLXLoader to use your way.
However, I will add both ways to the OpenDCL-FAQ (http://www.opendcl.com/forum/index.php?topic=1073.0) for loading the functions.
I wish all of you and your families a Merry Christmas, and industrious Santa Claus, restful holidays and a good start to a healthy and successful new decade.
Regards,
Fred
-
Kerry, call me stupid, but may I ask you a question?
When I have a mnl-file which is automatically loaded when the menu is loaded - which advantage could exist to work with autoload instead of loading the vlx from the mnl directly (except keeping the memory clear if the command is not needed)?
This was my MNL before I had started with Owens VLXLoader...
(if (not vlax-get-acad-object) (vl-load-com))
(defun c:sc_lvman_load (/ strFile strPath strRegPath)
(if (not c:sc_lvman)
(progn
(if (not (= (getenv "PROCESSOR_ARCHITECTURE") "x86"))
(setq strReg "SOFTWARE\\Wow6432Node\\euroGIS\\LVMan\\LVMan")
(setq strReg "SOFTWARE\\euroGIS\\LVMan\\LVMan")
); if
(if (setq strRegPath (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" strReg) "InstDir"))
(if (= (substr strRegPath (strlen strRegPath)) "\\")
(setq strPath strRegPath)
(setq strPath (strcat strRegPath "\\"))
); if
(progn
(princ "\nAn important registry key is missing. Please install LVMAN anew!\n")
(setq strPath "C:\\Programme\\euroGIS\\LVMan\\")
); progn
); if
(if (setq strFile (findfile (strcat strPath "lvman.vlx")))
(vl-load-all strFile)
(alert "\nCannot find the file LVMAN.VLX. Please install LVMAN anew!\n")
); if
); progn
); if
(princ)
); c:sc_lvman_load
(c:sc_lvman_load)
Fred
-
Fred, I AutoLOAD purely to save the startup time and memory if the app is not needed immediately .... think about batch processing etc :)
added:
and NO, I won't call you stupid 'cause I know you're NOT :-D
-
save the startup time
Yes, that's a good argument. But in this special case I should add another condition: the LVMAN is a palette containing document related information. I should add a condition for the case the palette is already loaded (then the VLX must be loaded immediately, to update the content) or - if not - to set the AUTOLOAD option like you did.
It's 3:30 in the night. It's time to go on thinking about it in bed... :wink:
Fred
-
sweet dreams :lol:
If you're like me you'll wake up in 2 hours with the solution :wink:
-
For when you wake up.
Could you set a variable to the blackboard when you initially start your app.
Then, when you start a new document, if the variable has the correct value you could run the initialisation/EventTrap code for the palette/modeless dialog.
This could be run in-line from the .MNL after you've defined the AutoStart stub.
-
I've just noticed on my RSS feed a present from Owen, posted today
http://otb.manusoft.com/2009/12/automatic-lisp-loading.htm
haven't tried it yet, but I'm sure it will be up to his exemplary standard.