乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 59|回复: 16

[编程交流] It used to work, but quit

[复制链接]

4

主题

17

帖子

13

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 09:25:16 | 显示全部楼层 |阅读模式
I wrote a simple list routine back in 1995 that was supposed to put an integer in a box (or circle) and increment the value the next time you picked a new point.  I have a block called memnum that is a rectangle with some text inside and another block that is a circle with some text inside called jn.
 
When I load the lisp it asks me my start number and a scale factor as it should, but the mem code just has "XXXX" inside the box and does not increment the value.  It hasbeen years since I have run this code and I don't see why it quit working.  Can some of you smart LISP folks see why it is not incrementing my value?  The MEM code puts a number in the box and the JOI code puts a number in a circle.
 
  1. ;; This lisp routine was written by George T. Watson on 5-10-95;; This routine will insert an incremented number in a box(defun c:mem (/ pt1 val scale )(setq val (getint "\nEnter member number to start with   "))(setq scale (getint "\nEnter scale factor   "))(while val(setq pt1 (getpoint "\nPick next Point"))       (command "insert" "memnum" pt1  scale "" "" val)       (setq val (1+ val)))  ; end of while loop)  ; end of defun;; This routine will insert an incremented number in a circle(defun c:joi (/ pt1 val scale )(setq val (getint "\nEnter Joint number to start with   "))(setq scale (getint "\nEnter scale factor   "))(while val(setq pt1 (getpoint "\nPick next Point"))       (command "insert" "jn" pt1  scale "" "" val)       (setq val (1+ val))) ; end of while loop) ; end of defun
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:30:42 | 显示全部楼层
Hi George,
 
Give this a shot mate:
 
  1. (defun c:mem ( / *error* block old pt scale val var ) (setq block "memnum")  ;; Block to be Inserted (defun *error* ( msg )   (if old (mapcar 'setvar var old))   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) ) (setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var)) (mapcar 'setvar var '(0 1)) (if   (or     (tblsearch "BLOCK" block)     (findfile (strcat block ".dwg"))   )   (if     (and (setq val (getint "\nEnter member number to start with: "))       (progn         (initget 6)         (setq scale (getint "\nEnter scale factor: "))       )     )     (while (setq pt (getpoint "\nPick next Point: "))       (command "_.-insert" block "_S" scale "_non" pt "" (itoa val))       (setq val (1+ val))     )   )   (princ (strcat "\n--> " block ".dwg not Found.")) ) (mapcar 'setvar var old) (princ))
 
I've added some error trapping to your routine to check for valid input and existence of the block to be inserted.
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 09:36:00 | 显示全部楼层
Set your attreq system variable to 1.
回复

使用道具 举报

7

主题

340

帖子

338

银币

初来乍到

Rank: 1

铜币
37
发表于 2022-7-6 09:39:34 | 显示全部楼层
I'm no lisp guru, but on my system it gives an error related to not being able to find "memnum.dwg".  If you have that block stored somewhere, you need to either add its location to the search path or move the drawing to one of them in your search path list.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:40:46 | 显示全部楼层
Actually this would probably be better to combine the two routines:
 
  1. (defun c:mem nil (InsertBlock "memnum" "\nEnter Member Number to start with: "))(defun c:joi nil (InsertBlock "jn"     "\nEnter Joint Number to start with: "))(defun InsertBlock ( block msg / *error* old pt scale val var ) (defun *error* ( msg )   (if old (mapcar 'setvar var old))   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) ) (setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var)) (mapcar 'setvar var '(0 1)) (if   (or     (tblsearch "BLOCK" block)     (findfile (strcat block ".dwg"))   )   (if     (and (setq val (getint msg))       (progn         (initget 6) (setq scale (getint "\nEnter scale factor: "))       )     )     (while (setq pt (getpoint "\nPick next Point: "))       (command "_.-insert" block "_S" scale "_non" pt "" (itoa val))       (setq val (1+ val))     )   )   (princ (strcat "\n--> " block ".dwg not Found.")) ) (mapcar 'setvar var old) (princ))
回复

使用道具 举报

4

主题

17

帖子

13

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 09:44:12 | 显示全部楼层
Lee Mac;
Thanks, that worked.
 
Alanjt;
Setting the system variable attreq to 1 (it was 0) worked with my original code.
 
Jack;
Yes, the little drawing memnum is just a rectangle with the text inside and it is my search path.
 
Thanks all for the help.  Back in 1995, I knew what I was attempting to do, but the years in between then and now have blurred the memory.
回复

使用道具 举报

7

主题

340

帖子

338

银币

初来乍到

Rank: 1

铜币
37
发表于 2022-7-6 09:49:19 | 显示全部楼层
 
Lee and some of these other folks have forgotten more than I ever knew about writing lisp.  I used to could take one that was close to what I wanted to do and massage it till it did what I wanted but lately haven't even had that much success.
 
You wanna draw something, I can be all up in that.  You wanna write a program to draw something, I'll be standing over on the side going "ooooo....pretty!"
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:53:17 | 显示全部楼层
 
Good to hear g****son
 
(lol at your name being censored)
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 09:58:08 | 显示全部楼层
t.wat are you talking about?
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 10:00:21 | 显示全部楼层
Yeah, I figured as much. Nothing wrong with what Lee gave you, but you should understand what was actually going wrong.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 03:29 , Processed in 0.475722 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表