乐筑天下

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

[编程交流] 记住用户输入以备将来使用

[复制链接]

15

主题

64

帖子

49

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-5 19:06:18 | 显示全部楼层
 
Satishrajdev,
 
所以我试着应用你的方法,它似乎对我不起作用,我百分之百肯定,因为我做得不对。
 
您将看到,我已经注释掉了请求radius的原始代码,并尝试了您的方法。我显然做得不对。。。
 
  1. ;;; JMPR.lsp
  2. ;;;
  3. ;;; Description
  4. ;;; Jumper will auto-create the radius jump for pipe crossings.
  5. ;;;
  6. ;;; Author: Lee Mac (CADTutor)
  7. ;;; Date: 03/25/10
  8. ;;;
  9. ;;; Revision: 1
  10. ;;; Revision Date: 10/30/15
  11. ;;; Description - Modified by David Prontnicki
  12. ;;; Added the ability to select your radius at the beginning of the command.
  13. ;;; Changed interface verbage
  14. ;;;
  15. ;;; Command: JMPR
  16. ;;; -----------------------------------------------------------------------------;
  17. (defun c:jmpr (/ *error* A AENT B1 B2 BDISA BDISB BENT DOC ENT OV P1 P2 UFLAG VL O W)
  18. ;(setq bDis (getreal "\n Enter new value for Jump Radius: ")) ; Modified by David Prontnicki
  19. (setq bDisa bDisb)
  20. (setq bDisb (getreal (strcat "\n Enter new value for Jump Radius "
  21.                 (if (not bDisa)
  22.                   ": "
  23.                   (strcat "<" (itoa bDisa) ">: ")
  24.                 )
  25.         )
  26. )
  27. )
  28. (if (and (not bDisb) bDisa)
  29. (setq bDisb bDisa)
  30. )
  31. (defun *error* (msg)
  32.    (and uFlag (vla-EndUndoMark doc))
  33.    (and ov  (mapcar (function setvar) vl ov))
  34.    (and msg (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  35.                 (princ (strcat "\n** Error: " msg " **"))))
  36.    (princ))
  37. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
  38.        vl '("PEDITACCEPT" "CMDECHO" "OSMODE") ov (mapcar (function getvar) vl))
  39. (setvar "PEDITACCEPT" 1)
  40. (while (and (setq uFlag (not (vla-StartUndoMark doc)))
  41.              (mapcar   (function setvar) (cdr vl) '(0 32))
  42.              (setq p1  (getpoint "\nPick the crossing intersection: ")) ; Modified by David Prontnicki
  43.              (setq ent (entsel "\nSelect the line to break: "))) ; Modified by David Prontnicki
  44.    (setq p2 (osnap (cadr ent) "_nea")
  45.          b1 (polar p1 (setq a (angle p1 p2)) bDisb)
  46.          b2 (polar p1 (+ pi a) bDisb))
  47.    
  48.    (setvar "OSMODE" 0)
  49.    (command "_.break" b1 b2)
  50.    (setq bEnt (entlast))
  51.    (if (> a (/ pi 2.))
  52.      (command "_.arc" b2 "_E" b1 "_A" 180.)
  53.      (command "_.arc" b1 "_E" b2 "_A" 180.))
  54.    (setq aEnt (entlast))
  55.    (if (eq "LWPOLYLINE" (cdr (assoc 0 (entget (setq ent (car ent))))))
  56.      (progn
  57.        (setq w (vla-get-ConstantWidth (setq o (vlax-ename->vla-object ent))))
  58.        (command "_.pedit" "_M" bEnt aEnt ent "" "_J" "" "")
  59.        (vla-put-ConstantWidth (vlax-ename->vla-object (entlast)) w)))
  60.    (setq uFlag (vla-EndUndoMark doc)))
  61. (*error* nil)  
  62. (princ))

 
提前谢谢!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:10:37 | 显示全部楼层
 
原因是您已将符号“bDis”声明为局部变量,因此该变量的范围仅限于c:jmpr函数;因此,每次计算c:jmpr函数时,“bDis”符号的一个新值被推送到堆栈上。
 
还要注意的是,变量“bDis”在提供给getreal函数的第一个有效输入之后将变成double,因此,itoa函数将失败-这应该是rtos。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:17:33 | 显示全部楼层
FWIW,这里有另一种写它的方法,它可能更容易理解,变量“bDis”仍然是局部的:
  1. (if (null myglobalvariable)
  2.    (setq myglobalvariable 1.0)
  3. )
  4. (if (setq bDis (getreal (strcat "\nJump Radius <" (rtos myglobalvariable) ">: ")))
  5.    (setq myglobalvariable bDis)
  6.    (setq bDis myglobalvariable)
  7. )
回复

使用道具 举报

15

主题

64

帖子

49

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-5 19:17:50 | 显示全部楼层
 
李·麦克,
 
你就是那个男人!谢谢你,也谢谢你解释它背后的理论。这意味着很多,真的帮助我学习。非常感谢。
回复

使用道具 举报

55

主题

402

帖子

357

银币

后起之秀

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

铜币
274
发表于 2022-7-5 19:24:25 | 显示全部楼层
 
我使用了GETINT,所以我使用了一个函数将整数转换为字符串。从GETREAL中,您将得到实数,从将其转换为字符串中,您必须使用RTOS。
 
如果您保留任何输入以供将来参考,那么您不应该像李先生提到的那样将其本地化。
  1. (/ *error* A AENT B1 B2 [color="red"]BDISA[/color] BDISB BENT DOC ENT OV P1 P2 UFLAG VL O W)

 
您的代码在此处更新:-
  1. ;;; JMPR.lsp
  2. ;;;
  3. ;;; Description
  4. ;;; Jumper will auto-create the radius jump for pipe crossings.
  5. ;;;
  6. ;;; Author: Lee Mac (CADTutor)
  7. ;;; Date: 03/25/10
  8. ;;;
  9. ;;; Revision: 1
  10. ;;; Revision Date: 10/30/15
  11. ;;; Description - Modified by David Prontnicki
  12. ;;; Added the ability to select your radius at the beginning of the command.
  13. ;;; Changed interface verbage
  14. ;;;
  15. ;;; Command: JMPR
  16. ;;; -----------------------------------------------------------------------------;
  17. (defun c:jmpr (/ *error* A AENT        B1 B2 BDIS BENT        DOC ENT        OV P1 P2 UFLAG
  18.        VL O W)
  19. ;(setq bDis (getreal "\n Enter new value for Jump Radius: ")) ; Modified by David Prontnicki
  20. (setq        bDis (getreal (strcat "\n Enter new value for Jump Radius "
  21.                       (if (not (setq bDisa bDis))
  22.                         ": "
  23.                         (strcat "<" (rtos bDisa) ">: ")
  24.                       )
  25.               )
  26.      )
  27. )
  28. (if (and (not bDis) bDisa)
  29.    (setq bDis bDisa)
  30. )
  31. (defun *error* (msg)
  32.    (and uFlag (vla-EndUndoMark doc))
  33.    (and ov (mapcar (function setvar) vl ov))
  34.    (and msg
  35. (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  36.      (princ (strcat "\n** Error: " msg " **"))
  37. )
  38.    )
  39.    (princ)
  40. )
  41. (setq        doc (vla-get-ActiveDocument (vlax-get-acad-object))
  42. vl  '("PEDITACCEPT" "CMDECHO" "OSMODE")
  43. ov  (mapcar (function getvar) vl)
  44. )
  45. (setvar "PEDITACCEPT" 1)
  46. (while (and (setq uFlag (not (vla-StartUndoMark doc)))
  47.       (mapcar (function setvar) (cdr vl) '(0 32))
  48.       (setq p1 (getpoint "\nPick the crossing intersection: "))
  49.                                 ; Modified by David Prontnicki
  50.       (setq ent (entsel "\nSelect the line to break: "))
  51. )                                ; Modified by David Prontnicki
  52.    (setq p2 (osnap (cadr ent) "_nea")
  53.   b1 (polar p1 (setq a (angle p1 p2)) bDis)
  54.   b2 (polar p1 (+ pi a) bDis)
  55.    )
  56.    (setvar "OSMODE" 0)
  57.    (command "_.break" b1 b2)
  58.    (setq bEnt (entlast))
  59.    (if        (> a (/ pi 2.))
  60.      (command "_.arc" b2 "_E" b1 "_A" 180.)
  61.      (command "_.arc" b1 "_E" b2 "_A" 180.)
  62.    )
  63.    (setq aEnt (entlast))
  64.    (if        (eq "LWPOLYLINE"
  65.     (cdr (assoc 0 (entget (setq ent (car ent)))))
  66. )
  67.      (progn
  68. (setq w        (vla-get-ConstantWidth
  69.           (setq o (vlax-ename->vla-object ent))
  70.         )
  71. )
  72. (command "_.pedit" "_M" bEnt aEnt ent "" "_J" "" "")
  73. (vla-put-ConstantWidth (vlax-ename->vla-object (entlast)) w)
  74.      )
  75.    )
  76.    (setq uFlag (vla-EndUndoMark doc))
  77. )
  78. (*error* nil)
  79. (princ)
  80. )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:27:28 | 显示全部楼层
 
非常欢迎你Cylis0509,很乐意帮忙。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 20:23 , Processed in 0.891683 second(s), 63 queries .

© 2020-2025 乐筑天下

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