100Jan Posted December 29, 2017 Share Posted December 29, 2017 I have Created Setup Program for my application. Application install fine and first VLX File load on Startup. Lock2Block.vlx Lock2BlockCmds.vlx (defun Lock2Block-GetAppFolder () (vl-string-right-trim "\\/" (cond ; Check all three possible registry locations ( (vl-registry-read "HKEY_CURRENT_USER\\Software\\MProjekt\\Lock2Block" "InstallPath") ) ( (vl-registry-read "HKEY_LOCAL_MACHINE\\Software\\Mprojekt\\Lock2Block" "InstallPath") ) ( (vl-registry-read "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\Mprojekt\\Lock2Block" "InstallPath") ) ( "" ) ) ) ) ;; Define autoload command stubs ;; * "Lock2BlockCmds" is the lisp filename that implements the commands (autoload (strcat (vl-string-translate "\\" "/" (Lock2Block-GetAppFolder)) "/" "Lock2BlockCmds") '( "L2B" "UNDOL2B" ) ) ( (lambda (/ trustedpaths appfolder startpos endpos found) (if (setq trustedpaths (getvar "TRUSTEDPATHS")) (progn (setq appfolder (Lock2Block-GetAppFolder)) (while (and (not found) (setq endpos (vl-string-position (ascii ";") trustedpaths endpos))) (setq found (eq (strcase appfolder) (strcase (substr trustedpaths (if startpos startpos (setq startpos 1)) (- (setq endpos (1+ endpos)) startpos) ) ) ) ) (setq startpos (1+ endpos)) ) (if (not found) (setq found (eq appfolder (substr trustedpaths (if startpos startpos 1))))) (if (not found) (setvar "TRUSTEDPATHS" (strcat trustedpaths ";" appfolder))) ) ) ) ) (princ "\nLock2Block loaded -- Command L2B and UNDOL2B are now available.\n") (princ) But when i try to Run command L2B from VLX file, I recieve error. The file /Lock2BlockCmds(.lsp/.exe/.arx) was not found in your search path folders. Check the installation of the support files and try again.nil So I guess My APP Folder is not in AutoCad TrustedPaths. Is there any way to put App Folder to TrustedPath ? Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 29, 2017 Share Posted December 29, 2017 (edited) Heres two interesting links: Add to Trusted Locations via lisp Add & Remove Support File Search Paths This is the conclusion I'm doing from the first link: (defun AddTrustedPaths ( Lpaths / v ) (and Lpaths (setq v (apply 'strcat (cons (cond ( (setq v (getvar 'trustedpaths)) (strcat v ";") ) ("")) (mapcar '(lambda (x) (strcat x ";")) Lpaths)))) (setvar 'trustedpaths v) ) ); defun AddTrustedPaths But I'm not sure if it works. EDIT: With brief testing seems to work: (AddTrustedPaths (list (acet-ui-pickdir))) Edited December 29, 2017 by Grrr Quote Link to comment Share on other sites More sharing options...
rlx Posted December 29, 2017 Share Posted December 29, 2017 Heres two interesting links: Add to Trusted Locations via lisp Add & Remove Support File Search Paths This is the conclusion I'm doing from the first link: (defun AddTrustedPaths ( Lpaths / v ) (and Lpaths (setq v (apply 'strcat (cons (cond ( (setq v (getvar 'trustedpaths)) (strcat v ";") ) ("")) (mapcar '(lambda (x) (strcat x ";")) Lpaths)))) (setvar 'trustedpaths v) ) ); defun AddTrustedPaths Never searched for this but now I see it I'm gonna use it , thanx Grrr! Gr. Rlx Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 29, 2017 Share Posted December 29, 2017 Never searched for this but now I see it I'm gonna use it , thanx Grrr! Gr. Rlx Me too, I was just aware only of Lee's LM:sfsp+ function, so its kinda new for me aswell. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 29, 2017 Share Posted December 29, 2017 I have set just about everything else and the missing one was so simple. Thanks Grrr. When we build a new pc just run the lisp Trusted paths was missing. Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 29, 2017 Share Posted December 29, 2017 No worries, BIGAL - the guys in that thread deserve the credit - the rest is just a bit of manipulation. Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 29, 2017 Share Posted December 29, 2017 (edited) I think this one would be better, since its more generic: ;| Sample Test Function: (defun test ( / dsktop ) (setq dsktop (strcat (getenv "userprofile") "\\Desktop\\")) ; "Trusted path for Test LSP functions" (foreach dir (mapcar '(lambda (x) (strcat dsktop x)) '("A" "B" "C")) (setenv "ACAD" (InsertDir nil dir (getenv "ACAD"))) (setvar 'trustedpaths (InsertDir nil dir (getvar 'trustedpaths))) ); foreach (princ) ); defun |; ; n - position to insert, if nil - it would be the very last ; dir - directory to add ; where - (getvar 'trustedpaths) or (getenv "ACAD") or.. ; returns: string with the included directory at nth position ; example: (setvar 'trustedpaths (InsertDir nil (acet-ui-pickdir) (getvar 'trustedpaths))) (defun InsertDir ( n dir where / f paths i r ) (cond ( (not (vl-every '(lambda (x) (eq 'STR (type x))) (list dir where))) ) ( (progn (and (not (findfile dir)) (vl-mkdir dir)) nil) ) ; attempt to create the directory if it doesn't exist ( (or (not (findfile dir)) (vl-string-search (strcase dir) (strcase where))) nil) ; check if its already there (so no duplicate) ( (progn (setq paths ((setq f (lambda ( s / i ) (if (setq i (vl-string-search ";" s)) (append (list (substr s 1 i)) (f (substr s (+ i 2)))) (list s)))) where)) nil) ) ( (eq 'INT (type n)) (setq i -1) (setq r (if (< n (length paths)) (apply 'strcat (apply 'append (mapcar (function (lambda (x) (setq i (1+ i)) (if (= i n) (list dir ";" x ";") (list x ";")))) paths))) (strcat where ";" dir) ) ) ) ( (setq r (strcat (apply 'strcat (mapcar '(lambda (x) (strcat x ";")) paths)) dir)) ) ); cond (cond (r)(where)) ); defun InsertDir Edited December 14, 2018 by Grrr Quote Link to comment Share on other sites More sharing options...
100Jan Posted December 30, 2017 Author Share Posted December 30, 2017 Uuu nice Its working... tnx Grrr... At last my code is complete. Now just upgrades BTW Ne of the best place here to seek help... Quote Link to comment Share on other sites More sharing options...
100Jan Posted December 30, 2017 Author Share Posted December 30, 2017 One more Question: If I read installation Path from registry with this code (defun Lock2Block-GetAppFolder () (vl-string-right-trim "\\/" (cond ; Check all three possible registry locations ( (vl-registry-read "HKEY_CURRENT_USER\\Software\\MProjekt\\Lock2Block" "InstallPath") ) ( (vl-registry-read "HKEY_LOCAL_MACHINE\\Software\\Mprojekt\\Lock2Block" "InstallPath") ) ( (vl-registry-read "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\Mprojekt\\Lock2Block" "InstallPath") ) ( "" ) ) ) ) Is there any way to load specific *.VLX from this directory EXAMPLE: Something like this (vl-load-all (Lock2Block-GetaAppFolder) "Lock2BlockCmds.vlx") because i don't know directory where user will install Application. So I want to read install path from registry and then load specific vlx from this directory... Sorry i'm new to Lisp Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 30, 2017 Share Posted December 30, 2017 After obtaining the path use load function in conjuction with vl-directory-files, or if you want to load from subdirectories aswell, then you'll need recursive subfunction like this. Makes me think does the trustedpath will support the subdirectories aswell. :thinking: Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 30, 2017 Share Posted December 30, 2017 100jan if you want things to work all the time then you need some rules, you need to create a installer so you know where the software is, you can use lisp or a a Bat file. ; make temp directory (if (vl-file-directory-p "C:\\Acadtemp\\") (Princ "Acadtemp exists") (vl-mkdir "C:\\AcadTEMP\\") ) here is something useful for upgrades. ; resets the paths 2016 usefull for update versions of Autocad ; by Alan H 2016 ; This sets a reference to the install path of your product ; the gets are their for info maybe other use ; use this to find other settings ;(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object))) T) (vl-load-com) (defun setpaths ( / *files* doc) ; make temp directory (if (vl-file-directory-p "C:\\Acadtemp\\") (Princ "Acadtemp exists") (vl-mkdir "C:\\AcadTEMP\\") ) (setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object)))) ; savepath ;(vla-get-AutoSavepath *files*) (vla-put-AutoSavepath *files* "C:\\AcadTemp") ; custom icons ;(vla-get-CustomIconPath *files*)) (vla-put-CustomIconPath *files* "P:\\Autodesk\\ICONS") ; custom menu ;(vla-get-Menufile *files*)) ;(vla-put-Menufile *files* "C:\\Users\\2013XXXX") ; printers config ;(vla-get-PrinterConfigPath *files*) (vla-put-PrinterConfigPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles 2011") ; printers style sheet ;(vla-get-PrinterStyleSheetPath *files*) (vla-put-PrinterStyleSheetPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles") ; printer drv's ;(vla-get-PrinterDescPath *files*) (vla-put-PrinterDescPath *files* "P:\\AutoDESK\\Plotting\\Drv") ; print spooler ;(vla-get-PrintSpoolerPath *files*) (vla-put-PrintSpoolerPath *files* "C:\\AcadTemp\\") ; template path ;(vla-get-TemplateDwgPath *files*) (vla-put-TemplateDwgPath *files* "P:\\Autodesk\\c3d Templates") ; template location ;(vla-get-QnewTemplateFile *files*) (vla-put-QnewTemplateFile *files* "P:\\Autodesk\\c3d Templates\\XXXX.dwt") ;make new support paths exist + new (setq paths (vla-get-SupportPath *files*)) (setq XXXXpaths "P:\\autodesk\\supportfiles;P:\\autodesk\\lisp;P:\\autodesk\\fonts;") (setq newpath (strcat XXXXpaths paths)) (vla-put-SupportPath *files* newpath) ; Tempdirectory ;(vla-get-TempFilePath *files*)) (vla-put-TempFilePath *files* "C:\\AcadTemp\\") ; PlotLogFilePath = "C:\\Documents and Settings\\whoisit.XXXX-AD\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\" (vla-put-PlotLogFilePath *files* "C:\\AcadTemp\\") ; LogFilePath = "C:\\Documents and Settings\\whoisit.XXXX-AD\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\" (vla-put-LogFilePath *files* "C:\\AcadTemp\\") ; xref temp path ;(vla-get-TempXrefPath *files*)) (vla-put-TempXrefPath *files* "C:\\AcadTemp\\") ; end use of *files* ) (setpaths) ; exit quitely (princ "All Done") Quote Link to comment Share on other sites More sharing options...
100Jan Posted December 31, 2017 Author Share Posted December 31, 2017 After obtaining the path use load function in conjuction with vl-directory-files, or if you want to load from subdirectories aswell, then you'll need recursive subfunction like this.Makes me think does the trustedpath will support the subdirectories aswell. :thinking: I made installer with Inno Setup. Program install ok and write data in registry. I use ARX Loader for program to start on AutoCad startup. Everithyng work fine with .lsp files. But when i set script to install vlx files, second vlx from install directory won`t load. I have two files First one to read registry, Make trusteth path, and set path to second command vlx file. So i think all i need is to call ssecond file with load function from installed directory. But problem is i dont know where user will install this program so i dont know where is the file. I must search with this code in earlier post GetAppFolder... And then somehow load vlx file. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 31, 2017 Share Posted December 31, 2017 @100jan: The function vl-list-loaded-vlx can be used to determine the path of a loaded vlx file. It may be useful in your scenario. Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 31, 2017 Share Posted December 31, 2017 (edited) The function vl-list-loaded-vlx can be used to determine the path of a loaded vlx file. It may be useful in your scenario. This made me curious about a similar function that works for lsp files. EDIT: Just found this snippet, which will retrieve the folder of the last apploaded lisp (not sure if that works with .vlx): (defun last-appload-folder ( ) ; LM ; http://www.cadtutor.net/forum/showthread.php?82830-List-of-a-loaded-lisps& (vl-registry-read (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\Appload") "MainDialog") ) Edited December 31, 2017 by Grrr Quote Link to comment Share on other sites More sharing options...
100Jan Posted January 1, 2018 Author Share Posted January 1, 2018 This made me curious about a similar function that works for lsp files. EDIT: Just found this snippet, which will retrieve the folder of the last apploaded lisp (not sure if that works with .vlx): (defun last-appload-folder ( ) ; LM ; http://www.cadtutor.net/forum/showthread.php?82830-List-of-a-loaded-lisps& (vl-registry-read (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\Appload") "MainDialog") ) I managed to do it with Merging All needed *.lsp and *.dlc into one vlx file. And then in Inno Setup Script changed all Registry path and .arx function to this *.vlx. Now Setup Install Program in (Program Files (x86) default) and then Auto Load This File when AutoCad strats, and everything working. But i will try to figure out how to load all needed vlx, dll... files from one main vlx. I have found this link http://www.manusoft.com/resources/arxtips/demandloadvlx.html Thx everyone for help and happy Coding holidays 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.