明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1332|回复: 0

[讨论] help me improve the environment (autolisp it's challange)

[复制链接]
发表于 2010-1-13 21:23:00 | 显示全部楼层 |阅读模式
Dear All,
It's possible every time cad open & alert msg box with image
new message or tips every day randomly with image
(sample msg)

Copy and print on both sides of paper.
Reuse items like envelopes, folders and paper clips.
Use mailer sheets for interoffice mail instead of an envelope.
Set up a bulletin board for memos instead of sending a copy to each employee.
Use e-mail instead of paper correspondence.
Use recycled paper.
Use discarded paper for scrap paper.
Encourage your school and / or company to print documents with soy-based inks, which are less toxic.
Use a ceramic coffee mug instead of a disposable cup.

(you can improve the environment)
autolisp code
  1. ;;; Quote generator
  2. ;;; Read quotes from Dat File
  3. (defun ReadQuotes (filDat / strDatFile filDatOpen txtNewLine lstQuotes)
  4. (setq filDatOpen (open filDat "r"))
  5. (while (setq txtNewLine (read-line filDatOpen))
  6. (setq lstQuotes (cons (read txtNewLine) lstQuotes))
  7. )
  8. (close filDatOpen)
  9. (setq lstQuotes (reverse lstQuotes))
  10. )
  11. ;;; Write quotes back to Dat File
  12. (defun WriteQuotes (filDat lstQuotes / filDirScript intCounter)
  13. (setq filDatOpen (open filDat "W"))
  14. (foreach strLine lstQuotes
  15. (print strLine filDatOpen)
  16. )
  17. (close filDatOpen)
  18. (princ)
  19. )
  20. ;;; Displays a quote from a selected Dat file
  21. ;;; The Dat file must have a blank line at the top and be in the following format
  22. ;;;(" Copy and print on both sides of paper. "0)
  23. ;;;(" Reuse items like envelopes, folders and paper clips. "0)
  24. ;;;...
  25. (defun c: goGreen (/ lstofQuotes lstNextRead lstMarkasRead)
  26. (if (setq filDat (findfile "gogreen.dat")); check for dat file
  27. (progn; if true
  28. (setq lstofQuotes (cdr (ReadQuotes filDat))); read dat file
  29. (setq intNextRead (vl-position '(0) (mapcar' (lambda (strQuote) (member '0 strQuote)) lstofQuotes))); check for the first 0 (un read line) in the file
  30. (if intNextRead
  31. (setq lstNextRead (nth intNextRead lstofQuotes)); if it finds an unread quote read it
  32. (progn; if not set all quotes to unread and read the first line in the file
  33. (setq lstofQuotes (mapcar '(lambda (lstQuote) (subst '0 '1 lstQuote)) lstofQuotes))
  34. (setq intNextRead (vl-position '(0) (mapcar' (lambda (strQuote) (member '0 strQuote)) lstofQuotes)))
  35. (setq lstNextRead (nth intNextRead lstofQuotes))
  36. )
  37. )
  38. (setq lstMarkasRead (subst '1 '0 lstNextRead)); change the 0 to 1 to mark that this quote has been read
  39. (setq lstofQuotes (subst lstMarkasRead lstNextRead lstofQuotes)); change this quote to read in the original list
  40. (WriteQuotes fildat lstofQuotes); re-write list of quotes in dat file to show it as read
  41. (alert (car lstNextRead)); notify user of quote
  42. )
  43. (progn; if GoGreen.dat not found
  44. (princ "\ nFile GoGreen.dat not found!"); notify user
  45. (setq fildat (vl-string-subst "dat" "lsp" (findfile "gogreen.lsp "))); find path of this lisp
  46. (setq lstofQuotes' (( "Copy and print on both sides of paper." 0)
  47. ( "Reuse items like envelopes, folders and paper clips." 0)
  48. ( "Use mailer sheets for interoffice mail instead of an envelope." 0)
  49. ( "Set up a bulletin board for memos instead of sending a copy to each employee." 0)
  50. ( "Use e-mail instead of paper correspondence." 0)
  51. ( "Use recycled paper." 0)
  52. ( "Use discarded paper for scrap paper." 0)
  53. ( "Encourage your school and / or company to print documents with soy-based inks, which are less toxic." 0)
  54. ( "Use a ceramic coffee mug instead of a disposable cup." 0))); create default list of quotes
  55. (WriteQuotes fildat lstofQuotes); create GoGreen.dat
  56. (princ "\ nNew GoGreen.dat file has been created."); notify user
  57. (setq lstofQuotes (cdr (ReadQuotes filDat))); read dat file
  58. (setq intNextRead (vl-position '(0) (mapcar' (lambda (strQuote) (member '0 strQuote)) lstofQuotes))); check for the first 0 (un read line) in the file
  59. (setq lstNextRead (nth intNextRead lstofQuotes)); read first unread quote
  60. (setq lstMarkasRead (subst '1 '0 lstNextRead)); change the 0 to 1 to mark that this quote has been read
  61. (setq lstofQuotes (subst lstMarkasRead lstNextRead lstofQuotes)); change this quote to read in the original list
  62. (WriteQuotes fildat lstofQuotes); re-write list of quotes in dat file to show it as read
  63. (alert (car lstNextRead)); notify user of quote
  64. )
  65. )
  66. (princ "\ nYou can improve the environment!"); notify user
  67. (princ)
  68. )
  69. (princ "\ nGoGreen.lsp is loaded. Type GoGreen to run."); notify user

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-23 03:32 , Processed in 0.219314 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表