TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Rustabout on January 27, 2023, 02:18:48 PM
-
Am I correct in saying that a DCL file will "become part" of the compiled code? And doesn't need to be stored in a separate place?
I think I know the answer to the second part but maybe I'm wrong: Slides (SLD files) don't become embedded into the application after compiling?
I can test the DCL part out quite easily but not so much the SLD part.
Thanks!!
-
I might be wrong here:
The only way to "compile" a DCL file is to create it at run time?
https://www.afralisp.net/dialog-control-language/tutorials/dcl-without-the-dcl-file-part-1.php
I swore I saw somewhere that you could just embed DCL's... I guess not.
-
OpenDCL allows for imbedding the compiled DCL data into the .LSP
https://sourceforge.net/projects/opendcl/
https://opendcl.com/forum/index.php
-
Thanks kdub. It looks like it's making a bit of a comeback?
-
You can write the code for the dcl in your lisp code, this little program will help do that if you have an existing dcl.
; LispWrapperForDCL
; code by RLX
(defun C:test ( / *error* src Sdes lsp Ddes row L tmp )
(defun *error* ( m )
(and (eq 'FILE (type Sdes)) (close Sdes))
(and (eq 'FILE (type Ddes)) (close Ddes))
(and (eq 'STR (type lsp)) (findfile lsp) (vl-file-delete lsp))
(and m (princ m)) (princ)
); defun *error*
(cond
( (not (setq src (getfiled "Specify DCL file" (strcat (getenv "userprofile") "\\Desktop\\") "dcl" 16))) (prompt "\nDCL file not specified.") )
( (not (setq Sdes (open src "R"))) (prompt "\nUnable to open the DCL file for reading.") )
(
(not
(princ ""
(setq Ddes
(open
(setq lsp
( (lambda (s / i tmp) (setq i 0) (while (findfile (setq tmp (strcat s "_" (itoa i) ".lsp"))) (setq i (1+ i))) tmp)
(apply (function (lambda (a b c) (vl-string-translate "/" "\\" (strcat a b)))) (fnsplitl src))
)
); setq lsp
"W"
); open
); setq Ddes
); princ
); not
(if lsp
(prompt (strcat "\nUnable to open '" lsp "' for writing."))
(prompt "\nUnable to generate the '.lsp' file.")
)
)
(t
;|
(while (setq row (read-line Sdes))
(write-line
(if (/= "" row)
(vl-list->string (append '(34) (apply 'append (subst '(92 34) '(34) (mapcar 'list (vl-string->list row)))) '(34)))
row
); if
Ddes
); write-line
); while
|;
(while (setq row (read-line Sdes))
(setq L
(cons
(if (/= "" row)
(vl-list->string (append '(34) (apply 'append (subst '(92 34) '(34) (mapcar 'list (vl-string->list row)))) '(34)))
; (vl-list->string (append '(34) (vl-string->list row) '(34)))
row
); if
L
)
); L
); while
(setq L (reverse L))
(foreach x
'("(defun C:test_LispWrapperForDCL ( / *error* dcl des dch dcf )"
(defun *error* ( m )
(and (< 0 dch) (unload_dialog dch))
(and (eq 'FILE (type des)) (close des))
(and (eq 'STR (type dcl)) (findfile dcl) (vl-file-delete dcl))
(and m (princ m)) (princ)
); defun *error*
"(and"
(setq dcl (vl-filename-mktemp nil nil ".dcl"))
(setq des (open dcl "W"))
"(progn"
"(foreach x " L
(write-line x des)
"); foreach"
"T"
"); progn"
(not (setq des (close des)))
(setq dch (load_dialog dcl))
(new_dialog "test" dch)
(= 1 (setq dcf (start_dialog)))
"); and"
(*error* null) ; <- use "null" instead of "nil", else its buggy!
(princ)
"); defun"
); list
(cond
( (eq 'STR (type x))
(and (setq tmp (vl-string->list x)) (not (apply '= (cons 32 tmp))) (write-line x Ddes) )
)
( (= x 'L) (foreach x (append '("'(") (eval x) '(")")) (write-line x Ddes)) )
( (vl-consp x)
(princ "(" Ddes)
(foreach x (list (car x) (cadr x) (caddr x))
(if x
(princ (strcat (strcase (vl-prin1-to-string x) t) " ") Ddes)
)
)
(mapcar '(lambda (x) (write-line (strcase (vl-prin1-to-string x) t) Ddes)) (cdddr x))
(write-line ")" Ddes)
)
)
); foreach
((lambda (L) (mapcar 'set L (mapcar 'close (mapcar 'eval L)))) '(Sdes Ddes))
(
(lambda ( fpath / shell )
(if fpath
(vl-catch-all-apply
(function
(lambda nil
(setq shell (vlax-get-or-create-object "Shell.Application"))
(vlax-invoke-method shell 'Open fpath)
)
)
)
)
(vl-catch-all-apply 'vlax-release-object (list shell))
)
lsp
)
(load lsp)
(if C:test_LispWrapperForDCL
(C:test_LispWrapperForDCL)
(alert "Unable to define the generated lisp!")
)
(setq lsp nil)
); t
)
(*error* nil) (princ)
); defun
-
Thanks kdub. It looks like it's making a bit of a comeback?
Don't think it ever went away :)
but, have you read this
from https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-D39EA37A-4248-4F05-A822-0F41EA4ECF68
AutoCAD also provides features for packaging complex AutoLISP applications into a Visual LISP executable (VLX) file also known as an application module. VLX files can include additional resources files, such as TXT and DCL files, and compiled AutoLISP code. Using VLX files, you can further control your application's operating environment by exposing only those functions you choose to expose, and by maintaining a wall between your program's variables and the variables users can interact with in AutoCAD.
-
Thanks BIGAL - I might use that next time. I had been just manually plug my dialog's text into the LISP file... tedious...
kdub: I recall that the only hitch with OpenDCL was that each user has to install something? Not a big deal but I think back in the day that was the only reason I avoided it (that and the modest learning curve... wasn't great with dialog's back then). After that I moved onto .NET and would have an easier time doing WinForms opposed to learning OpenDCL. Kind of a shame and stupid looking back on it now...
I just noticed that Solidworks now supports OpenDCL as of last year. There also seems to be more resources available. If I had to learn both from scratch, and I were only doing AutoCAD programming, I would definitely go towards OpenDCL opposed rather than WinForms. It took a while to figure .NET out.
-
I write all my dcl's now as part of my lisp code that is what the Vl temp file is doing you just write the dcl using write-line.
Have a look at attached as an example, there is a couple of ways of doing it but must be careful of "Label" and others which need the " dbl quote.
Some of my code has multiple dcl's in the lisp.
The program I posted earlier writes a dcl as lisp code you insert that into your code. Give it a try if get stuck post.
Else post the dcl and will convert.
-
Thanks BIGAL!
I do that as well, pretty much ala the AftraLISP tutorial. The ability to dynamically create DCL tiles is quite potent and actually easier than more modern interfaces.
As I learn .NET the more I realize how easy and practical AutoLISP really is.
-
.net has advantages when can not say get "inside", look at draw rectang compared to lisp how many lines of code.
-
Thanks BIGAL - . . .
. . . After that I moved onto .NET and would have an easier time doing WinForms opposed to learning OpenDCL. Kind of a shame and stupid looking back on it now...
I just noticed that Solidworks now supports OpenDCL as of last year.
. . .
where, when ?
https://www.theswamp.org/index.php?topic=57639.0
no answer from Owen !
-
OpenDCL not only needs lisp, it needs an ObjectARX style interface for the C++ side. Does Solidworks have that?
-
I think I'm wrong. Here's the post that may be causing my confusion:
https://www.theswamp.org/index.php?topic=57639.0
Maybe I just saw the title and made an assumption. I thought there was something else somewhere as well but I can't find it.
I can't find any other evidence that it supports OpenDCL. But in theory they could implement a version of OpenDCL for Solidworks if the demand was there?
-
I think its wrong, I see DraftSight has visual lisp functions, I didn't even see a lisp or C++ API for solidworks, except via COM
DraftSight uses ODA code, so I'm not sure whats available for DraftSight C++. if it's Teigha, I wouldn't expect a pot anytime soon.
though a DraftSight user might explore of there's a connection between .NET and their lisp API via ResultBuffer
-
I finally got around to reading this:
https://www.afralisp.net/visual-lisp/tutorials/compiling-part-2.php
After a bit of confusion I think I finally got compiling more or less figured out.
My one question is that it seems that you can in fact embed DCL files into a VLX file? The VLX file is self contained and users don't have to drag a DCL around everywhere with it? Based on how I've read AfraLISP's tutorial.
I had some issues with this in the past (probably something I did wrong*) which is why I just started writing the DCL at run time. But if the above is true I would rather compile everything in the future.
If I'm mistaken please let me know :-)
*And.... I just remembered my problem and the solution: I tend to prefer very long file names. The compiler has a character limit apparently, so files with names over 'x' amount of characters cause an error when trying to compile.
Thanks!!
-
http://bbs.mjtd.com/thread-185632-1-1.html?_dsign=7e173f72