乐筑天下

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

[编程交流] DCL和Lisp插入点a

[复制链接]

7

主题

34

帖子

27

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 18:52:57 | 显示全部楼层 |阅读模式
这是我的挑战:
我需要一个例程,该例程将提示用户在交点处插入一个点,然后将该点从edit_box值移动给定距离。当前有4个按钮可供选择以移动点,上、左、右和下,以及标准的“确定”、“取消”。
目前,我的代码将插入一个点,表单将显示以提示用户移动距离,但在此之后,我将绕圈尝试找出如何从edit_框中设置值。此外,该值需要以英寸为单位,不确定如何处理除a(val/12)以外的其他值。拼图的最后一块将是从原始插入点交点插入一个维度到点的新位置,然后返回到我们提示用户在交点插入点的开始处。谢谢大家的意见,我真的很感激。
目前为止的代码:
DCL:
  1. //DCL CODING STARTS HERE
  2. move_pt
  3. : dialog
  4. {
  5. label = "Move Points";
  6. : column {
  7. : row {
  8. : button {label = "UP"; key = "up";
  9.                 width = 6;}
  10. }
  11. }
  12. : column {
  13. : row {
  14. : button {label = "LEFT"; key = "left";
  15.                  width = 6;}
  16. : edit_box {key = mval; width = 7; value = "";
  17.                 alignment = centered;}
  18. : button {label = "RIGHT"; key = "right";
  19.                  width = 6;}
  20. }
  21. }
  22. : column {
  23. : row {
  24. : button {label = "DOWN"; key = "down";
  25.                 width = 6;}
  26. }
  27. }
  28. : column {
  29. : row {
  30.        
  31. : button {label = "OK"; key = "accept";        mnemonic = "O";
  32.                 width = 6; is_default = true;}
  33. : button {label = "Cancel"; key = "cancel";        mnemonic = "c";
  34.                 width = 6;}
  35.        
  36. }
  37. }
  38. }

 
Lisp程序:
  1. (defun c:edgept ()
  2. ;define the function
  3. (defun saveVars()
  4. (setq mval( distof (get_tile "mval")))
  5. )
  6. (defun doButton(a)
  7. (cond
  8. ((= a 1)(command "._move" (entlast) "" (list 0 (/ mval 12) 0) ""))
  9. ((= a 2)(command "._move" (entlast) "" (list [color="red"]((* mval -1)/ 12)[/color] 0 0) ""))
  10. ((= a 3)(command "._move" (entlast) "" (list (/ mval 12) 0 0) ""))
  11. ((= a 4)(command "._move" (entlast) "" (list 0 [color="red"]((* mval -1)/ 12)[/color] 0) ""))
  12. )
  13. )
  14. ;********************************************************
  15. (setvar "CLAYER" "COVER")
  16. (setq pt (getpoint "\Choose intersection you are measuring from: "))
  17. (command "._point" pt)
  18. (setq dcl_id (load_dialog "move_pt.dcl"))
  19.     (if (not (new_dialog "move_pt" dcl_id))
  20. (exit)
  21.     );end if
  22. (action_tile
  23.       "cancel"
  24.       "(done_dialog 1)")
  25. (action_tile
  26. "up" "(saveVars) (doButton 1)(done_dialog)")
  27. (action_tile
  28. "left" "(saveVars) (doButton 2)(done_dialog)")
  29. (action_tile
  30. "right" "(saveVars) (doButton 3)(done_dialog)")
  31. (action_tile
  32. "down" "(saveVars) (doButton 4)(done_dialog)")       
  33. (start_dialog)                                        ;start dialog
  34. (unload_dialog dcl_id)
  35. (if(= done_diaglog 1)
  36.            (princ "\n  cancelled!")
  37.          )
  38. (princ)
  39. )
  40. (princ)

 
编辑:我已经更新了上面的代码,我被红色的“mval”的负值卡住了。
并且仍然需要从原点到新pt位置的尺寸。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:57:43 | 显示全部楼层
你好
 
只需简单介绍一下这四个按钮。
例如,如果用户按下,点对象应移动到的新位置或新坐标在哪里?然后是其他按钮。
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 19:02:34 | 显示全部楼层
你可以为你的点做一个块,但一个点可以,用entlast在你的程序中选择它,将你的距离值存储在一个全局值或一个autocads用户变量中
 
USERI1–5存储和检索整数值
USERR1–5存储和检索实数
USERS1–5存储和检索文本字符串数据
 
然后,当用户向上按时,使用move(entlast)@您的距离
 
存储插入点和新的“极轴”点时,可以对其进行尺寸标注。
 
祝你好运
 
gr.Rlx
回复

使用道具 举报

7

主题

34

帖子

27

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 19:09:54 | 显示全部楼层
 
塔尔瓦特,
绝对如此。
假设用户在edit_框中键入15,则这四个按钮将用户从原始插入点插入的点移动到沿y轴的点“示例”+15(如果按下up),沿x轴的点移动到+15(如果按下right),沿y轴的点移动到-15(如果按下down),沿x轴的点移动到-15(如果按下left)。我编辑了上面的代码
  1. (defun doButton(a)
  2. (cond
  3. ((= a 1)(command "._move" (entlast) "" (list 0 (/ mval 12) 0) ""))
  4. ((= a 2)(command "._move" (entlast) "" (list (/ (* mval -1) 12) 0 0) ""))
  5. ((= a 3)(command "._move" (entlast) "" (list (/ mval 12) 0 0) ""))
  6. ((= a 4)(command "._move" (entlast) "" (list 0 (/ (* mval -1) 12) 0) ""))

所以实际上我所有的按钮现在都工作了,我只需要维度部分。
最后,我意识到这是在游戏后期添加的,但我想知道,然后连接一条线穿过所有的点有多难。
回复

使用道具 举报

7

主题

34

帖子

27

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 19:10:42 | 显示全部楼层
 
我很想看看这是如何应用的,我会努力用这个,谢谢。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 19:14:42 | 显示全部楼层
很清楚,你不需要在每个动作块中都使用dobutton函数,尽管新坐标列表是错误的,无论如何,我明天早上会发布正确的代码,因为现在已经很晚了。
 
还有一件事是,需要删除许多额外的列和行函数,并且编辑框的关键字必须是字符串。
回复

使用道具 举报

7

主题

34

帖子

27

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 19:20:14 | 显示全部楼层
 
我同意它需要清理很多,这是第7-8关在它,我承认我不是最干净的哈哈。非常感谢您的帮助。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 19:23:52 | 显示全部楼层
你能避免同时使用dcl吗?为什么不使用CHX CHY呢?只要简单的LISP,并提供移动量的正值或负值。如果需要,你还可以使用系数/12等。在循环中,只需不断拾取要移动的对象,很容易更改为先获取点。
 
  1. (defun c:PTX ( / Pt mvamount))
  2. (setq oldsnap (getvar "osmode'))
  3. (setq pt (getpoint "pick point"))
  4. (setvar "osmode" 0)
  5. (command "point" pt)
  6. (setq mvamount (getreal "Enter value"))
  7. (Command "Move" "L" "" (list 0 0 0) (list mvamount 0 0))
  8. (setvar "osmode" oldsnap)
  9. )
回复

使用道具 举报

7

主题

34

帖子

27

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 19:28:17 | 显示全部楼层
 
我想使用dcl,因为这将由没有任何CAD培训的个人使用,基本上我需要编写所有的前端命令和变量,同时保持一个干净的界面。这只是过程中的一个组成部分。记住,他们不知道也无法访问所有命令。这就像定制产品的第一步,最后一步将由熟练的技术人员设计。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 19:34:39 | 显示全部楼层
试试这个程序,让我知道它是如何与你合作的。
 
DCL代码:
 
  1. move_pt : dialog { label = "Move Points";
  2.    : button {
  3.                    label = "UP";
  4.                    key = "up";
  5.                    width = 6;}
  6.    : row {
  7.    : button {
  8.                    label = "LEFT";
  9.                    key = "left";
  10.                    width = 6;}
  11.    : edit_box {
  12.                    key = "mval";
  13.                    width = 7;}
  14.    : button {
  15.                    label = "RIGHT";
  16.                    key = "right";
  17.                    width = 6;}
  18.            }
  19.    : button {
  20.                    label = "DOWN";
  21.                    key = "down";
  22.                    width = 6;}
  23.    : row {
  24.    : button {
  25.                    label = "OK";
  26.                    key = "accept";
  27.                    mnemonic = "O";
  28.                    width = 8;
  29.                    is_default = true;}
  30.    : button {
  31.                    label = "Cancel";
  32.                    key = "cancel";
  33.                    mnemonic = "c";
  34.                    width = 8;
  35.                    is_cancel = true;
  36.                    }   
  37. }}

 
  1. (defun c:test (/ pt obj id e p)
  2. ;; Tharwat 14.07.2015        ;;
  3. (if (tblsearch "LAYER" "COVER")
  4.    (setvar "CLAYER" "COVER")
  5.    )
  6. (if (zerop (getvar 'pdmode))
  7.    (setvar 'pdmode 3)
  8.    )
  9. (if (setq
  10.        pt (getpoint "\nChoose intersection you are measuring from: ")
  11.        )
  12.    (setq obj (entmakex (list '(0 . "POINT") (cons 10 pt))))
  13.    )
  14. (vla-regen (vla-get-activedocument (vlax-get-acad-object))
  15.             acallviewports
  16.             )
  17. (if (and obj
  18.           (< 0 (setq id (load_dialog "move_pt.dcl")))
  19.           (new_dialog "move_pt" id)
  20.           )
  21.    (progn
  22.      (setq e (entget obj)
  23.            p (cdr (assoc 10 e))
  24.            )
  25.      (defun number-p ()
  26.        (or (eq (get_tile "mval") "")
  27.            (zerop (atoi (get_tile "mval")))
  28.            )
  29.        )
  30.      (action_tile
  31.        "up"
  32.        "(if (number-p)(progn
  33.                         (mode_tile "mval" 2)
  34.                         (alert "Contents of Edit box is either not numbers or null !"))
  35.                         (progn
  36.                            (entmod (append e (list (cons 10 (list (car p) (+ (cadr p) (read (get_tile "mval"))) (caddr p))))))
  37.                            (done_dialog))) "
  38.        )
  39.      (action_tile
  40.        "left"
  41.        "(if (number-p)(progn
  42.                         (mode_tile "mval" 2)
  43.                         (alert "Contents of Edit box is either not numbers or null !"))
  44.                            (progn
  45.                            (entmod (append e (list (cons 10 (list (- (car p) (read (get_tile "mval"))) (cadr p) (caddr p))))))
  46.                            (done_dialog)))"
  47.        )
  48.      (action_tile
  49.        "right"
  50.        "(if (number-p)(progn
  51.                         (mode_tile "mval" 2)
  52.                         (alert "Contents of Edit box is either not numbers or null !"))
  53.                            (progn
  54.                            (entmod (append e (list (cons 10 (list (+ (car p) (read (get_tile "mval"))) (cadr p) (caddr p))))))
  55.                            (done_dialog)))"
  56.        )
  57.      (action_tile
  58.        "down"
  59.        "(if (number-p)(progn
  60.                         (mode_tile "mval" 2)
  61.                         (alert "Contents of Edit box is either not numbers or null !"))
  62.                            (progn
  63.                            (entmod (append e (list (cons 10 (list (car p) (- (cadr p) (read (get_tile "mval"))) (caddr p))))))
  64.                            (done_dialog)))"
  65.        )
  66.      (action_tile "accept" "(done_dialog)")
  67.      (action_tile "cancel" "(done_dialog)")
  68.      (start_dialog)
  69.      (unload_dialog id)
  70.      )
  71.    (if (< 0 id)
  72.      (unload_dialog id)
  73.      )
  74.    )
  75. (princ)
  76. )(vl-load-com)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 13:35 , Processed in 1.185597 second(s), 72 queries .

© 2020-2025 乐筑天下

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