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

LISP based on variables defined in the LISP file

7 REPLIES 7
Reply
Message 1 of 8
pfilters
527 Views, 7 Replies

LISP based on variables defined in the LISP file

I have a very limited amount of knowledge and experience in creating LISP routines, but i have been able to get by.

 

Every two weeks, I print out a time sheet (attached) for each of our employees showing the current pay period dates which is manually filled out by the employee with hours worked.  I have to manually edit the name on the time sheet and print it out for every person.  i developed the attached LISP to speed up the process and it works great.  What i would like to do is have a list of variables in the LISP file, one for each employee name, and have the routine reference the variables so i can more easily manage personnel changes by adding or subtracting the variables in the list.  

 

this is way beyond my capabilties.  can anyone help me do this?  i asuume the LISP could be setup to run for n amount of variables and know that it's finished when it reaches the end of the list so all i have to do is maintain the list and not edit the code.

7 REPLIES 7
Message 2 of 8
Kent1Cooper
in reply to: pfilters


@pfilters wrote:

.... 

Every two weeks, I print out a time sheet (attached) for each of our employees showing the current pay period dates which is manually filled out by the employee with hours worked.  ....  What i would like to do is have a list of variables in the LISP file, one for each employee name, and have the routine reference the variables so i can more easily manage personnel changes by adding or subtracting the variables in the list.

....


CAD doesn't seem like the best way to go about this.  Could you do it as a word-processor document instead, and use a feature such as what I believe some word processors call Mail Merge?  I think that kind of thing is specifically designed to do this kind of thing.
 

But if you want to stick with the .DWG approach, you could probably do something like this, using not variables but just a list of names [untested]:

 

(foreach x '("LYNN" "ANTHONY" "CHRIS" "TIM" "BRAD")

  (command "-attedit" "n" "n" "header" "employee" "*" "-" x "-plot" "" "" "" "" "" "" "" "_u")

); foreach

 

The undo at the end should set the value back to - after the iteration for each name, so you don't need to look for a different current value each time.

 

Then you could just add or remove names from that employee names list as needed.

Kent Cooper, AIA
Message 3 of 8
pfilters
in reply to: Kent1Cooper

Thanks.  i had to make the following changes, though:

 

(defun c:tc ()

(foreach x '("LYNN" "ANTHONY" "CHRIS" "TIM" "BRAD")

  (command "-attedit" "n" "n" "header" "employee" "*" "-" x "-plot" "" "" "" "" "" "" "" "_u" "_u")

))

 

the first undo only undid the plot, so i added another. i also added a parentheses at the end to counter the one prior to "defun".  Lastly, I removed the "; foreach" from the end because i didnt understand it, and it works without it.

 

I'll admit, it took me a while to understand how this all fit together with the "(defun c:tc ()" portion missing from your explanation.  i actually had it running as soon as the drawing opened for a while there.  Neat, but not practical.

 

Anyway, this was exactly what i was looking for.  i'd never heard of the "foreach" function.  I'll try to use it in another LISP sometime.  Thanks so much.  

Message 4 of 8
Kent1Cooper
in reply to: pfilters


@pfilters wrote:

Thanks.  i had to make the following changes, though:

 

(defun c:tc ()

(foreach x '("LYNN" "ANTHONY" "CHRIS" "TIM" "BRAD")

  (command "-attedit" "n" "n" "header" "employee" "*" "-" x "-plot" "" "" "" "" "" "" "" "_u" "_u")

))

 

the first undo only undid the plot, so i added another. i also added a parentheses at the end to counter the one prior to "defun".  Lastly, I removed the "; foreach" from the end because i didnt understand it, and it works without it.

.... 


Ah, of course -- I didn't have an undo in there for both the Plot and the Attedit, as of course you would need.  The "; foreach" was just there to identify that the right parenthesis it follows is the closing one for the (foreach) function -- some people would [and I generally used to, until recently]  say "; end foreach" to make that more explicit, but I've taken to omitting the word "end" lately.  And in a shorter function like this, it's not as important to identify what a closing parenthesis is closing -- it means more when you have a long series of nested functions.  But yes, it certainly will work without it -- anything following a semicolon is just commentary, which has no operational effect.

Kent Cooper, AIA
Message 5 of 8
scot-65
in reply to: pfilters

Give this some thought in taking your routine to the next level:

 

Create a dialog interface using list_box to display the employee names.

Add buttons along the bottom to "Add", "Remove", "Sort", and "Print".

 

Above the list_box, use popup_lists for the month, day, and year for "From" and "Thru".

 

The print button would be the "Accept" trigger that would only be pressed once.

 

Here's something similar I developed not too long ago, given this same general idea:

 

PNotes01.gif

 

THIS IS WHAT YOU ARE LOOKING FOR:

Data storage in the form of a LIST inside the Dictionary.

Access using VLAX-LDATA-GET.

Then do the FOREACH...

 

🙂


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


Message 6 of 8
pbejse
in reply to: scot-65


@scot-65 wrote:

 Here's something similar I developed not too long ago, given this same general idea:

 

 

Data storage in the form of a LIST inside the Dictionary.

Access using VLAX-LDATA-GET.

Then do the FOREACH...

 

🙂


Nice Idea scot-65.

Message 7 of 8
dbroad
in reply to: pfilters

I had a similar system about 15 years ago before I switched to using spreadsheets to manage this task.  The spreadsheet option has been much easier to implement and manage and has worked very nicely.  I can log out and in of any project quickly, annotate what I did and automate bill production.  A database solution would probably have been better.  If I was thinking about changing systems now however, I would think about using an out-of-the-box solution like Quick Books. Waste of time to do this stuff in drawings with lisps IMO.

 

Good luck.

Architect, Registered NC, VA, SC, & GA.
Message 8 of 8
scot-65
in reply to: pfilters

Here's something I put together this morning - maybe a total of one hour spent on it.

There is still a little more *inside* work that is needed to get it to a point where you

will be able to incorporate what you have now to make it work.

 

Test03.gif

 

I personally don't like to see command UNDO inside LISP.

Instead of ATTEDIT, Start with -INSERT, then -PLOT, then Erase (entlast).

And (setvar "ATTDIA" 0) is required here.

 

🙂


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


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

Post to forums  

Autodesk Design & Make Report

”Boost