Author Topic: Compiling multiple lisps into one larger lisp...  (Read 8235 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« on: June 02, 2004, 06:49:36 PM »


That is my Electrical toolbar.  I am writing a lisp for each button, but I don't want 19 seperate lisp files.  Each button inserts a block.  The lisp will put the block on it's correct layer.  I am aware I can just add the change command after the insertion macro, but I want to add a TBLSEARCH "LAYER" to each one to make sure the layer exists, and if not, then it would create it.

How would I go about arranging them within 1 lisp file, and how would the buttons call the correct lisp?  I'm guessing I make one lisp named "Electrical.lsp" with each button having it's own defun.  Something along the lines of...

Code: [Select]
Electrical.lsp
**********************
(defun c:button1 ()
          ----------
          ----------
)

(defun c:button2 ()
          ----------
          ----------
)

(defun c:button3 ()
          ----------
          ----------
)


And then each button macro would just be "^C^C_button1" "^C^C_button2"  etc....

Is all this correct??? :twisted:

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Compiling multiple lisps into one larger lisp...
« Reply #1 on: June 02, 2004, 07:38:23 PM »
[quote="Dommy2HottyAnd then each button macro would just be "^C^C_button1" "^C^C_button2"  etc....

Is all this correct??? :twisted:[/quote]

Yes, however I would suggest a slightly different strategy. I'm going out on a limb here and assume that you have your toolbar in it's own mnu/mns file, instead of the base acad menu. If not, I strongly suggest you do. This will make upgrades, re-installs, further customization, etc, much easier to manage.
Now, based on that, create a .mnl file that mimics the name of your menu file. Such as: your toolbars are in MyElectric.mns so create a MyElectric.mnl file. Now place all of the button defuns into this mnl file and they will always load with the menu.

edited to show the use of files having the same name, not similar names....thanks to Slim for catching that.

Just my $0.02....
Jeff    :idea:[/i]

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Compiling multiple lisps into one larger lisp...
« Reply #2 on: June 02, 2004, 07:43:03 PM »
Quote from: Jeff Mishler
MyElectric.mns so create a MeElectric.mnl file.


Both should be MyElectric.*, Right Jeff. :)  :wink:
I drink beer and I know things....

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #3 on: June 02, 2004, 07:55:11 PM »
.. and further to that ..
Change the command names to  c:elec_button01  .. etc .. or similar to ensure the names are unique, and wont overwrite the button01 command from the next menu toolbar that you write.

Re the layer setting command : I assume that would be a stand alone library routine called from each buttonxx command. .. rather than just repeat a block of code in each routine.
Sort of like this :-
Code: [Select]

;;; Elect_tb1.mnl file
(vl-load-com)

(defun myChangeLayerCommand (LayerName / )
;;
;;
;Do Layer change stuff here ..
; < snip >
)

(defun c:Elect_tb1_01 ( / prevLayer)
;save prevLayer
(myChangeLayerCommand "ElecBlocks")

; < snip >
; < do your stuff here >

;restore prevLayer
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Compiling multiple lisps into one larger lisp...
« Reply #4 on: June 02, 2004, 07:56:18 PM »
Nice stuff, Kerry :D
I drink beer and I know things....

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #5 on: June 03, 2004, 11:40:58 AM »
AHHH.....yes....mnl files...buh-duh....

ok...now what's up with the (vl-load-com) stuff...

a pointing to a website for the vla, vlax, ex-lax or whatever that is would be nice...have to learn it sooner or later... :twisted:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #6 on: June 03, 2004, 11:49:18 AM »
Quote
ok...now what's up with the (vl-load-com) stuff...

a pointing to a website for the vla, vlax, ex-lax or whatever that is would be nice


RTFM will work.

.. and you're welcome.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Compiling multiple lisps into one larger lisp...
« Reply #7 on: June 03, 2004, 11:54:25 AM »
Quote from: Kerry Brown
RTFM will work.
I can verify that. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #8 on: June 03, 2004, 12:41:02 PM »
Quote from: Kerry Brown
Quote
ok...now what's up with the (vl-load-com) stuff...

a pointing to a website for the vla, vlax, ex-lax or whatever that is would be nice


RTFM will work.

.. and you're welcome.


Pardon my ignorance...but now what's RTFM :crazy:

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Compiling multiple lisps into one larger lisp...
« Reply #9 on: June 03, 2004, 12:50:11 PM »
"read the fine manual" the word "fine" can be substituted with another word of four letters.
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #10 on: June 03, 2004, 12:53:12 PM »
RTFM is a specialist technical consulting organisation for the solving of difficult problems.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Compiling multiple lisps into one larger lisp...
« Reply #11 on: June 03, 2004, 12:55:11 PM »
Quote from: Kerry Brown
RTFM is a specialist technical consulting organisation for the solving of difficult problems.


lmao 2 points for Kerry. :D
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #12 on: June 03, 2004, 12:57:43 PM »
:D  They will also do peoples homework, If asked properly.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Anonymous

  • Guest
Compiling multiple lisps into one larger lisp...
« Reply #13 on: June 03, 2004, 01:02:52 PM »
RTFM is a powerful tool that every competent developer continually uses, and surprisingly, the very thing that frequently prevents casual coders from evolving. No attitude here, just statin' facts.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #14 on: June 03, 2004, 01:08:50 PM »
Quote
.. No attitude here, just statin' facts.


Even if it was attitude, I wouldn't apologise. ... attitude is what keeps me at this game.


:)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Compiling multiple lisps into one larger lisp...
« Reply #15 on: June 03, 2004, 01:09:12 PM »
Quote from: Anonymous
RTFM is a powerful tool that every competent developer continually uses, and surprisingly, the very thing that frequently prevents casual coders from evolving. No attitude here, just statin' facts.
Oops. Sorry, thought I was logged in; my bad.

= All your lisp are belong to us =
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #16 on: June 03, 2004, 01:15:09 PM »
Quote from: MPuckett

= All your lisp are belong to us =


lol...that's funny stuff....

I don't take offense to anything said...it's understandable...just be warned that if it happens again, I'll have to punchasize your face :twisted:






just kidding....

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Compiling multiple lisps into one larger lisp...
« Reply #17 on: June 03, 2004, 01:18:13 PM »
Quote
I don't take offense to anything said


.. you're no fun at all !!
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Compiling multiple lisps into one larger lisp...
« Reply #18 on: June 03, 2004, 01:24:50 PM »
Quote from: Dommy2Hotty

... I'll have to punchasize your face ...
A wise person once said:

"You can do anything you wish ... you only have to pay the consequences."
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #19 on: June 03, 2004, 01:36:35 PM »
Quote from: Kerry Brown
Quote
I don't take offense to anything said


.. you're no fun at all !!


well, I know I'm a n00b at this stuff...so I expect to be made fun of for stupid questions...

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #20 on: June 07, 2004, 04:39:50 PM »
Okay...got it all compiled, works perfectly (to the best of my knowledge).  Just one more question:  Does having the LISP's in a .mnl file take up memory like loading a LISP file thru the acad2004.lsp's Autoload section?  Or does it only load each LISP when it's called by the button?  Just wondering :twisted:

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Compiling multiple lisps into one larger lisp...
« Reply #21 on: June 07, 2004, 04:48:19 PM »
It all depends on how you set it up in the .mnl file. But if it were me I wouldn't worry about it that much with todays computers and the amount of ram thay have.
TheSwamp.org  (serving the CAD community since 2003)

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Compiling multiple lisps into one larger lisp...
« Reply #22 on: June 07, 2004, 05:18:22 PM »
Quote from: Mark Thomas
It all depends on how you set it up in the .mnl file.


Just like as follows, but with 19 total defun's for the 19 buttons on the toolbar.  Only difference between them is the defun name, block name, one different insert option on some, and one is on a different layer than the rest.

Code: [Select]

;;; Electrical.mnl file
;;; Dominic Cesare
;;; Last update: Fri June 4, 2004

;Duplex Outlet
(defun c:Duplex_Outlet (/ oldsnaps oldecho oldlayer block)
  ;error trapping
  (setq temperr *error*)
  (setq *error* trap1)
  ;storing current variables
  (setq oldlayer (getvar "clayer")
oldsnaps (getvar "osmode")
oldecho (getvar "cmdecho")
)
  ;turning snaps and echo off
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  ;prompts user to select insertion point and rotation
  (prompt "\nSelect Insertion Point and Rotation.....")
  ;inserting block
  (command "-insert" "r1001" "nea" pause "" "" pause)
  ;setting the inserted block to "block"
  (setq block (entlast))
  ;creating PL-ELEC-FIXTURE layer if not present
  (if (not (tblsearch "layer" "PL-ELEC-FIXTURE"))
    (command ".layer" "m" "PL-ELEC-FIXTURE" "C" "3" "" "")
    )
  ;changing inserted block to the PL-ELEC-FIXTURE layer
  (command "change" block "" "p" "la" "PL-ELEC-FIXTURE" "")
  ;resetting system variables
  (setvar "clayer" oldlayer)
  (setvar "osmode" oldsnaps)
  (setvar "cmdecho" oldecho)
  ;error trapping
  (setq *error* temperr)
  ;ending silently
  (princ)
  )
;error trapping
(defun trap1 (errmsg)
  (command "u")
  (setvar "clayer" oldlayer)
  (setvar "osmode" oldsnaps)
  (setvar "cmdecho" oldecho)
  (setq *error* temperr)
  (prompt "Resetting System Variables.....")
  (princ)
  )

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Compiling multiple lisps into one larger lisp...
« Reply #23 on: June 07, 2004, 06:18:54 PM »
Sorry, my mistake. I did not understand what you were doing.  :oops:

IMO, the way you have it setup is fine, all the defun's in the .mnl file will be ready to use everytime you open a dwg. i.e. their are all loaded at once. My custom .mnl file is much the same way, except I have more than 19 in mine!! The programs I use on ocassion say once a day I load as needed, like so;
Code: [Select]

(defun c:program () (if (not c:program)(load "program")))

that way it's not loaded until I need it.
TheSwamp.org  (serving the CAD community since 2003)