TheSwamp

Code Red => VB(A) => Topic started by: Matersammichman on June 27, 2006, 01:27:39 PM

Title: How do I load VLX and LISP files with VBA?
Post by: Matersammichman on June 27, 2006, 01:27:39 PM
1. What command can I use to load a VLX file with VBA?  :realmad:

2. What command can I use to load  a LISP file?  :pissed:
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 01:37:30 PM
You could use sendcommand
Title: Re: How???
Post by: Matersammichman on June 27, 2006, 01:46:33 PM
True, but if I can load ARX and DVB with VBA, why not Lisp and Visual Lisp?
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 01:55:04 PM
Because AutoCAD VBA doesn't have a built in LoadLSP method.  Of course, you can load Lisp and Visual Lisp, just maybe not the way you want to.  There's a better than even chance that referencing a library will allow you to achieve your desired results but if so, someone else will have to chime in on it.
Title: Re: How???
Post by: Matersammichman on June 27, 2006, 02:23:17 PM
Bob,
I'm having a bad brain day...could you drop me a complete line of example code to modify?
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 02:28:10 PM
thisdrawing.sendcommand "(load ""lispname.lsp"")" & vbcr

ought to work
Title: Re: How???
Post by: MP on June 27, 2006, 02:39:05 PM
ThisDrawing.SendCommand "(load ""lispname.lsp"" 'doh)" & vbCr
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 02:42:28 PM
'doh?
Title: Re: How???
Post by: Maverick® on June 27, 2006, 02:43:52 PM
Re, Me, Fa, So, La, Ti, Do   
Title: Re: How???
Post by: MP on June 27, 2006, 02:48:25 PM
Sure.

ThisDrawing.SendCommand "(load ""lispname.lsp"" 'crapweasel)" & vbCr

ThisDrawing.SendCommand "(load ""lispname.lsp"" (alert ""Load knackered.""))" & vbCr

yada ...

But generally speaking I wouldn't use --

ThisDrawing.SendCommand "(load ""lispname.lsp"")" & vbCr
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 02:52:33 PM
OK, he asked a question that no one else was answering, I gave him an answer that works.  If you don't like it, instead of knocking it why don't you dazzle us with your fucking brilliance and show him a better way.
Title: Re: How???
Post by: MP on June 27, 2006, 02:56:50 PM
OK, he asked a question that no one else was answering, I gave him an answer that works.  If you don't like it, instead of knocking it why don't you dazzle us with your 42616E6E656400[/b]ing brilliance and show him a better way.

No need to go hexipostal. I was just demonstrating the optional argument you can pass the load statement so it returns something more illuminating or desirable than --

[0.43] (VL-BT)
[1.39] (*ERROR* "LOAD failed: \"lispname.lsp\"")
[2.34] (_call-err-hook #<SUBR @0312b078 *ERROR*> "LOAD failed:
\"lispname.lsp\"")
[3.28] (sys-error "LOAD failed: \"lispname.lsp\"")
:ERROR-BREAK.23 nil
[4.20] (LOAD "lispname.lsp")
[5.15] (#<SUBR @03288be0 -rts_top->)
[6.12] (#<SUBR @02a22334 veval-str-body> "(load \"lispname.lsp\")" T #<FILE
internal>)
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:ARQ-SUBR-CALLBACK.3 (nil 0)
Title: Re: How???
Post by: Matersammichman on June 27, 2006, 03:05:59 PM
Bob,

So...If its on a drive other than "C"
say "G",
do I need to path it "G:\..." :ugly:
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 03:07:38 PM
MP:

Sorry, I misunderstood and it was uncalled for regardless.  Looks like I probably shouldn't be in public today.

MSM:
If the lisp is in your support path you don't need to path it, if it's not you do.
Title: Re: How???
Post by: MP on June 27, 2006, 03:09:47 PM
Carry on Bob, bigger things to worry about; all is cool.
Title: Re: How???
Post by: Atook on June 27, 2006, 03:13:38 PM
..ThisDrawing.SendCommand "(load ""lispname.lsp"" (alert ""Load knackered.""))" & vbCr..


MP:

Are there too many quotes in the alert line?

(load "lispname.lsp" (alert "Load knackered.")) works for me, but I had to delete some of the quotes.

With the extra quotes the load tossed a binky..  :-D
Title: Re: How???
Post by: Matersammichman on June 27, 2006, 03:14:56 PM
 :wink:It's all good...
All I had to do was add double backslashes.

Thanks all!
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 03:47:08 PM
Atook, as a lisp statement, (load "lispname.lsp" (alert "Load knackered.")) is correct.  If you want that to work from vba though, it needs to be ThisDrawing.sendcommand "(load ""lispname.lsp"" (alert ""Load knackered.""))"

Double quotes("") in a string in VBA add a single quote(") to the string.  It's pretty much the same reason that you have to use a double backslash (\\) in lisp.
Title: Re: How???
Post by: David Hall on June 27, 2006, 04:21:00 PM
Dont toss the binky....
Title: Re: How???
Post by: Atook on June 27, 2006, 04:33:12 PM
Thanks for pointing that out Bob, I should have seen it.

I always used Chr$(34) for a quote in VB6, but never had to evaluate a quote in VBA.

Good to know.
Title: Re: How???
Post by: Bob Wahr on June 27, 2006, 05:10:27 PM
heh, missed the tossed the binky.  Chr$(34)/Chr(34)   works in VBA as well, I just couldn't remember the number so "" was easier.  AFAIR, "" works in VB6 as well.  When it gets down to it, it probably doesn't matter which way you skin the cat as long as it ends up on the fish hook.