+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Forum Newbie
    Discipline
    Civil
    Using
    Civil 3D 2010
    Join Date
    Dec 2017
    Posts
    5

    Default How to add My Application folder to TRUSTEDPATH

    Registered forum members do not see this ad.

    I have Created Setup Program for my application.
    Application install fine and first VLX File load on Startup.
    Lock2Block.vlx
    Lock2BlockCmds.vlx

    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")
          )
          ( ""
          )
        )
      )
    )
    
    
    ;; 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 ?

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,216

    Default

    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:
    Code:
    (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)))
    Last edited by Grrr; 29th Dec 2017 at 08:01 pm.

  3. #3
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    670

    Default

    Quote Originally Posted by Grrr View Post
    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:
    Code:
    (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

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,216

    Default

    Quote Originally Posted by rlx View Post
    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.

  5. #5
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,020

    Default

    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.
    A man who never made mistakes never made anything

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,216

    Default

    No worries, BIGAL - the guys in that thread deserve the credit - the rest is just a bit of manipulation.

  7. #7
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,216

    Default

    I think this one would be better, since its more generic:

    Code:
    ; 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 (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
      r
    ); defun InsertDir
    Last edited by Grrr; 30th Dec 2017 at 01:31 am.

  8. #8
    Forum Newbie
    Discipline
    Civil
    Using
    Civil 3D 2010
    Join Date
    Dec 2017
    Posts
    5

    Default

    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...

  9. #9
    Forum Newbie
    Discipline
    Civil
    Using
    Civil 3D 2010
    Join Date
    Dec 2017
    Posts
    5

    Default

    One more Question:

    If I read installation Path from registry with this code

    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

  10. #10
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,216

    Default

    Registered forum members do not see this ad.

    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:

Similar Threads

  1. LISP that creates a folder and a file inside the folder.
    By Ahmeds in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 13th Dec 2013, 11:14 pm
  2. Cad Application Add-ons?
    By skipsophrenic in forum Useful Links
    Replies: 10
    Last Post: 7th Apr 2009, 10:04 am
  3. VB to select input folder and output folder
    By TroutKing in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 7th Jun 2007, 11:07 pm
  4. registered application??
    By Domdeezy in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 9th Jan 2007, 11:49 am
  5. How to run this application?
    By Cadastrophic in forum AutoCAD General
    Replies: 3
    Last Post: 4th Mar 2004, 09:27 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts