Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i need to load a lisp routine with a toolbar button

19 REPLIES 19
Reply
Message 1 of 20
rhots
5234 Views, 19 Replies

i need to load a lisp routine with a toolbar button

Hi, I won't bore you with the reasons, but I need to load a lisp routine by way of a toobar button. I do not want to use the appload dialog box.

Thanks for your time,

Rick

19 REPLIES 19
Message 2 of 20
dbroad
in reply to: rhots

Use the CUI to create a new command.  The command string should look something like.  "^c^c^p(load "mypath\\mylispprogram").  Associate an icon of your choice with it and choose which toolbar to put it on.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 20
rhots
in reply to: dbroad

That is a start, thanks. Here is the thing.What I really need to do is have the ability to switch back and forth between 2 different lisp routines. What you sent me loaded the file perfectly. So I made 2 buttons, one for each lisp. The original was always loaded through acaddoc.lsp. So with your help I can load the second one. Here is the problem. Lets say I have 2 lisps, A&B. "A" is loaded already, your button loads "B". Now if I use the appload dialog box and and pick "A", it reloads it and makes it current. I can go back to the dialog box later, pick "B" and it reloads it and makes that current.

Using the buttons does not "reload" the lisp. So it is not "switching" back and forth as I need. Is there a way to "unload" then "reload"?

Thanks again for your time,

Rick

Message 4 of 20
hmsilva
in reply to: rhots

The "A" lisp is  in acaddoc.lsp, is loadded, or, is a text line as (autoload "MyPath/Mylisp" '("Mydefun"))?

 

if all lisp is written in acaddoc.lisp you nead to reload it.

 

^C^C^P(load "MyPath/acaddoc.lisp"))

 

if you only have a autoload, then

 

^C^C^P(load "MyPath/MyLisp"))

 

 

EESignature

Message 5 of 20
rhots
in reply to: hmsilva

Thanks for the reply. I am not sure what you mean in the first line. Acaddoc "calls" or loads the first lisp. Recalling it as you sugested does not make it current again as I need.

Thakns anyway,

Rick

Message 6 of 20
hmsilva
in reply to: rhots

My suggestion is not  recalling, is reloading.

if is reload it willmake it current.

 

Henrique

EESignature

Message 7 of 20
rhots
in reply to: hmsilva

Okay, how do I do that?

Message 8 of 20
dbroad
in reply to: rhots

I would recommend that you completely change your strategy.  2 separate lisp files should not redefine the same command.  Make them separate commands or functions and don't muddy the waters by having your users swap them out, never knowing which one is current without pushing a toolbar.

 

 

Architect, Registered NC, VA, SC, & GA.
Message 9 of 20
rhots
in reply to: dbroad

Okay, these 2 files are huge lisp routines. First let me say the 2nd lsp. Is a direct copy of the original. That said....A small, but important  part of what they do is set global block insertion scale and text size. They set a base so to speak. Then on a menu a scale is selected and the text or blocks are sized according to the base size set in the lisp routines.

We are now working to 2 standards in the office. New is larger blocks and text, old or original is smaller.

We may be working on more than one job at a time, thus the need to switch back and forth.

Thanks,

Rick

Message 10 of 20
dbroad
in reply to: rhots

Since "a huge lisp file" is usually much smaller than any drawing file, and since these lisp files are related to individual projects so that only one is used for any single project, I recommend that during the transition period of switching from one standard to another, that you just copy the relevant lisp file to your project folder and launch autocad by clicking on drawing file in that folder.

 

Load statements placed in acaddoc.lsp will load the lisp in the current folder before loading one in a search path if you do not include a path in your load statement.

 

Afterwards, you might rethink your entire strategy.  If the scalling is related to units, then newer versions of AutoCAD will automatically scale the drawings to particular units sizes.

 

Using appropriate project template drawing files should be a solution to most of your problems without any programming.

 

Annotation scaling problems can be accomodated by using the annotation scaling system.

Architect, Registered NC, VA, SC, & GA.
Message 11 of 20
rhots
in reply to: dbroad

Thanks for your help. That won't fly, this is part of a larger menu system. It is all intigrated. We'll get there somehow.

Thanks again

Message 12 of 20
hmsilva
in reply to: rhots

Rick,

with the buttons you can solve the problem, as I said.

 

if your lisp "A" is written inside acaddopc.lsp you nead to reload, using

 

^c^c( load "yourfilepath/acaddoc.lsp")

 

if is a external file,

 

^c^c( load "yourfilepath/yourfilename")

 

Cheers

Henrique

EESignature

Message 13 of 20
scot-65
in reply to: rhots


@rhots wrote:

A small, but important  part of what they do is set global block insertion scale and text size. They set a base so to speak. Then on a menu a scale is selected and the text or blocks are sized according to the base size set in the lisp routines.

Thanks,

Rick


Sounds to me like you need to store these settings inside the drawing file itself, that way no matter

what drawing you have opened, the settings can be obtained internally without all that switching...

 

Look into VLAX-LDATA-PUT and VLAX-LDATA-GET.

If there are many (more than one) items (base) to store, use LIST.

Access the list using NTH.

 

Example:

 

(VL-LOAD-COM)

(VLAX-LDATA-PUT "MyMenu" "Base" (list 1.0 4.5 "Standard"))

 

(if (not (setq a (VLAX-LDATA-GET "MyMenu" "Base")))

 (setq a (list 1.0 4.5 "Standard"))

);if

(setvar "DIMSCALE" (nth 0 a))

(setvar "TEXTSIZE" (nth 1 a))

(setvar "TEXTSTYLE" (nth 2 a))

...

 

Your routine(s) can be reworked rather easily.

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 14 of 20
jcarey
in reply to: hmsilva

Hello,

I know this is an old post, anyone still there?

Message 15 of 20
hmsilva
in reply to: jcarey


@Anonymous wrote:

Hello,

I know this is an old post, anyone still there?


Hello!!!!

EESignature

Message 16 of 20
jcarey
in reply to: hmsilva

Hi there,

I didn't have success creating a toolbar button for my lisp routine.

Any more pointers?

Thanks.

Message 17 of 20
hmsilva
in reply to: jcarey


@Anonymous wrote:

Hi there,

I didn't have success creating a toolbar button for my lisp routine.

Any more pointers?

Thanks.


Hi jcarey 

try

(if (not c:YourCommandName)(load "YourLispFileName"));YourCommandName;

 

Hope this helps,
Henrique

EESignature

Message 18 of 20
jcarey
in reply to: hmsilva

Thank you.

Message 19 of 20
hmsilva
in reply to: jcarey


@Anonymous wrote:

Thank you.


jcarey, did It worked as expected?

 

Henrique

EESignature

Message 20 of 20
jcarey
in reply to: hmsilva

I haven’t tried it yet.

I’ll post again after/if I get the opportunity.

Thanks!


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost