Jump to content

compiling vlx file and load from .lsp


Recommended Posts

Posted (edited)

Hello everyone!

 

I'm trying to make a .vlx file that will run some autolisp code using code from other lisp files.

 

To be more specific:

 

I have:

main routine.lsp

(defun c:santonis ( / )


  (load "voithitiko.lsp")

  (alert (strcat "sum=" (itoa (adder 6 1))))

  )

 

and here is a very small and simple .lsp file that I want to load functions from named voithitiko.lsp:

(defun adder ( a b / )

  (+ a b)

  )

 

I've tried adding voihthiko.lsp to either Lisp File to include and Resource Files to include [following the guide here https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-6C3ED4E0-039A-4707-96E8-080FA30EF79D] but had no luck. Currently my .prv files looks like this:

 

;;; Visual LISP make file [V1.0] anter saved to:[C:/Users/antonisg/Dropbox/douleia/autolisp_grafeio/vlx_sense] at:[10/19/23] 
(PRV-DEF (:target . "anter.VLX")
     (:active-x . T)
     (:separate-namespace)
     (:protected . T)
     (:load-file-list
       (:lsp "main_routine.lsp")
       (:lsp "voithitiko.lsp")
     )
     (:require-file-list)
     (:ob-directory)
     (:tmp-directory)
     (:optimization . st)
)
;; EOF

 

And here it what I get when I drag the vlx and trying to run my main function:

 

Command: (LOAD "C:/Users/antonisg/Dropbox/douleia/autolisp_grafeio/vlx_sense/anter.VLX") nil
Command: SANTONIS
; error: LOAD failed: "voithitiko.lsp"

 

Any help would be greatly appreciated. Thanks in advance!

 

 

Edited by meinfilel
  • meinfilel changed the title to compiling vlx file and load from .lsp
Posted (edited)

voithitiko.lsp has to be in a folder trusted locations or support path when only calling it out by name (load "voithitiko.lsp")

 

0EM3A000000FqVa.png.fd23412034fbef2fa3e6d9a2397c4b24.png

 

or use the full path (load "C:/Users/antonisg/Dropbox/douleia/autolisp_grafeio/voithitiko.lsp")

 

--Edit

https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-F3639BAA-FD70-487C-AEB5-9E6096EC0255

Quote

Important: Starting with AutoCAD 2014-based products, custom applications must work under secure mode; when the SECURELOAD system variable is set to 1 or 2. When operating under secure mode, the program is restricted to loading and executing files that contain code from trusted locations; trusted locations are specified by the TRUSTEDPATHS system variable.

 

Edited by mhupp
  • Thanks 1
Posted (edited)

But my main purpose is to send a single .vlx file to users that won't have access to voithiko.lsp

 

Is it something that can be done with compiling to .vlx?

 

Thanks for the response.

Edited by meinfilel
Posted (edited)

From what I know vlx is just complied lisp code that is encrypted. you can have multiple lisp commands in one file just need to have their own (defun C:command ()

 

--Edit

I did this as well. had like 20-50 or so commands in one encrypted file. added a help command that would list out all the commands and basic description in an alert box as well create a text file in their my documents so they would stop emailing me "what was that one command"

 

Quote

(defun C:lisp1 ()

  ;code

)

(defun C:lisp2 ()

   ;code

)

(defun C:lisp3 ()

   ;code

)

 

Edited by mhupp
Posted

Ok, I see.

 

I still think there must a way to do what I want though. It's not convenient to copy every time from my master file with the subfunctions to each file I want to send to other users so that each lisp contains everything it needs. Moreover, why can we load more than one lisp file for the vlx if not for the purpose I describe?

 

Thanks!

Posted (edited)

I think I got it working.

 

main_routine.lsp (I guess there is not need for loading adder function explicitly by (load "voithitiko.lsp") since it's being loaded when the .vlx starts)

(defun c:santonis ( / )


  (alert (strcat "sum=" (itoa (adder 6 1))))

  )

 

and

;;; Visual LISP make file [V1.0] anter saved to:[C:/Users/antonisg/Dropbox/douleia/autolisp_grafeio/vlx_sense] at:[10/19/23] 
(PRV-DEF (:target . "anter.VLX")
     (:active-x . T)
     (:separate-namespace)
     (:protected . T)
     (:load-file-list
       (:lsp "voithitiko.lsp")
       (:lsp "main_routine.lsp")
     )
     (:require-file-list)
     (:ob-directory)
     (:tmp-directory)
     (:optimization . st)
)
;; EOF

 

all i did is changing the order of .lsp files at this tab

image.png.8ab7cf4cd70b50904e6738ec543f3947.png

Edited by meinfilel
  • Like 1
Posted (edited)

When compiling, a vlx file and fas files are created.

the fas file is created for each lsp file,

and the vlx file contains all lsp files within it.

 

compiling multiple lsp files into vlx does not mean that each lsp file remains inside of vlx file

system automatically optimizes them and combines them into one code file. like mhupps lsp code.

so you cannot load them with (load "xxx.lsp"), If a file with the same name does not exist in that path...

 

so you can choose between loading a single vlx file or multiple fas files.

no need to load both vlx, fas, (of course no need to load already compiled lsp files It is already loaded when you load vlx.)

 

but, it is no longer the 'main loader'. because when vlx file loaded, all its functions on the system at once.

the main reason for using this feature is in old PCs, the lsp file loaded like this had a impact on speed.

 

so i think, changing the order is not affect to that situation.

(unless it is an lsp file that calls itself without inputting command)

i think the error has been resolved simply by removing the (load "~~~.lsp") statement.

 

 

Edited by exceed
  • Like 2
Posted

You are correct, order doesn't matter, I checked it after reading your post.

 

My goal was to "combine" .lsp subfunctions into a single file (which doesn't have readable code to third users) such that when I need a subfunction from fileA.lsp and another from fileB.lsp (fileA and fileB have tens of subfuctions that maybe change in the future) I just "import" them from there.

 

And when I change my subfunction in fileA.lsp I don't have to go to the "merged" .lsp and manually copy/paste the new function.

 

Thank you both for your time.

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...